SOLUTION
Venn Diagram for the problem is shown below
Now from the Venn Diagram the number at the center of the intersection of all three circles is 6. This represents the number of students that liked all three subjects.
Number that liked Math and Science is 18, So number that liked "Math and Science only", will be 18 (all the people that like Math and Science) minus 6 (numbers that liked all three subjects). This becomes 12.
This was how 4 (numbers that liked science and social studies