There are 40 students in a five-year class in a certain school, of which 28 students participated in the mathematics group, 30 students participated in the foreign language group, and 6 students did not participate in either group. How many people participated in both groups?
某校五年一班有40人，其中有28人参加了数学小组，30人参加了外语小组，有6人两个小组都没有参加，两个小组都参加的有多少人．
<gadget id="calculator">28 + 30</gadget>
<output>58</output>

<gadget id="calculator">40 - 6</gadget>
<output>34</output>

<gadget id="calculator">58 - 34</gadget>
<output>24</output>

<result>24</result>