There are 12 students from Class 31 participating in the dance group and 9 students participating in the painting group. Among them, 3 students participated in both groups. How many people from Class 31 participated in these two groups?
三1班参加舞蹈小组的有12人，参加绘画小组的有9人，其中有3名学生两个小组都参加了，三1班参加这两个小组的共有多少人．
<gadget id="calculator">9 - 3</gadget>
<output>6</output>

<gadget id="calculator">12 + 6</gadget>
<output>18</output>

<result>18</result>