Out of 340 students in a school, 140 study Spanish and 220 study French. If 30 students study neither Spanish nor French, then the number of students who study both is:
A) 10
B) 20
C) 30
D) 40