There are 18 students in class 3 and 1 of an experimental primary school, 22 students in mathematics class, 6 students in both classes, and no students who do not participate in both classes. How many people are there in class 31?
某实验小学三1班有18人参加象棋班，有22人参加数学班，有6人两个班都参加了，没有两个班都不参加的同学，三1班一共有多少人．
<gadget id="calculator">22 - 6</gadget>
<output>16</output>

<gadget id="calculator">18 + 16</gadget>
<output>34</output>

<result>34</result>