There are 19 students in the Chinese extracurricular group in the third grade, and 17 students in the mathematics extracurricular group. Among them, 5 students participate in both the Chinese and math groups. How many people are there in these two groups?
三年级参加语文课外小组的同学有19人，参加数学课外小组的同学有17人，其中有5人既参加语文小组又参加数学小组，这两个小组共有多少人？
<gadget id="calculator">17 - 5</gadget>
<output>12</output>

<gadget id="calculator">19 + 12</gadget>
<output>31</output>

<result>31</result>