Let P be the number of pupils that took the exam.

We know that 0.7P pupils got question 1 correct and that 0.6P got question 2 correct. Since 9 students go both problems correct they are counted twice (once for question 1 and again for question 2). So we have overcounted by 9 students. So we get the equation

So the number of pupils that took the exam was 30.

I hope this helps. Good luck.