There are a total of 40 students in the third grade class. All students participate in at least one activity class. There are 18 students in the composition class, 20 students in the music class, and 17 students in the Mathematical Olympiad class. There are 8 people, 6 people who take part in both the composition class and the music class, and 9 people who take part in both the Olympiad class and the composition class. How many students take part in the three activity classes at the same time?
三年级一班共有学生40名，所有学生至少参加一个活动班，参加作文班的有18人，参加音乐班的有20人，参加奥数班的有17人，既参加音乐班又参加奥数班的有8人，既参加作文班又参加音乐班的有6人，既参加奥数班又参加作文班的有9人，问同时参加三个活动班的学生有多少人？
<gadget id="calculator">8 + 6 + 9</gadget>
<output>23</output>

<gadget id="calculator">18 + 20 + 17</gadget>
<output>55</output>

<gadget id="calculator">55 - 40</gadget>
<output>15</output>

<gadget id="calculator">23 - 15</gadget>
<output>8</output>

<result>8</result>