Jimmy you are focusing on the original number too much... 42 students total... 22 do history... 17 do biology...
8 of the students do both history and biology... so the pure history number now becomes 14 and the pure biology number now becomes 9 and there is a the third number of 8 that do both...
seeing as 8 of the 17 that do biology also do history the number of students that do biology but not history is 9...
the number of students that are studying a history or biology class is the 14+9+8 which totals to 31
the total number of students is 42
take 31 from 42 and you are left with the number of students that are neither studying history or biology