Problem 6. Forty children were playing in a ring. Of them, 22 were holding hands with a boy and 30 were holding hands with a girl. How many girls were in the ring? [8 points] (E.V. Bakayev)
Answer: 24 girls.

Solution: $22+30=52$, so $52-40=12$ children held hands with both a boy and a girl. Therefore, $30-12=18$ children held hands only with girls. These 18 children held $18 \cdot 2=36$ girls' hands, and the other 12 held one girl's hand each, so the girls had a total of $36+12=48$ hands. Thus, there were $48: 2=24$ girls.

Comment: An arrangement of children in a circle that meets the conditions of the problem exists, for example, as shown in the figure. Other arrangements are possible.

![](https://cdn.mathpix.com/cropped/2024_05_06_79cfe44052259f2639fcg-07.jpg?height=263&width=785&top_left_y=1249&top_left_x=334)

Knowing the answer (24 girls and, therefore, 16 boys), we can observe that the number of girls is greater than the number of boys by exactly the same amount by which the number of children holding a girl's hand is greater than those holding a boy's hand: $24-16=30-22=8$. This is not a coincidence. Knowing this fact, the problem can be easily solved. However, proving this fact is not very simple. We will provide one possible proof.

Let $Д$ and $M$ be the number of girls and boys in the circle, and let $X$ and $Y$ be the number of children holding a girl's hand and a boy's hand, respectively.

Consider several (more than one) girls standing in a row. Ask them to leave the circle one by one—first those in the "middle" (i.e., standing between two girls), and then, when only two girls remain, one of the remaining. We will track how $Д, M$, and $Д-M$, as well as $X$, $Y$, and $X-Y$, change. We will create a table (using the small letter "д" to denote the girl leaving the circle):

|  | Д | $\bar{M}$ | $\bar{Д}-M$ | $\bar{X}$ | $\bar{Y}$ | $\overline{X-Y}$ |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| ...ДдД... | -1 | no change | -1 | -1 | no change | -1 |
| ...МдДМ... | -1 | no change | -1 | -2 | -1 | -1 |

We see that the differences $Д-M$ and $X-Y$ change in the same way (decrease by 1) with the departure of each girl. We will do the same with rows of boys—similarly, we can show that both differences will increase by 1 with the departure of each boy from the circle.

After all this, we will have a circle where boys and girls alternate, meaning there are an equal number of each, and $Д-M=0$. But $X-Y=0$ as well, because in this case $X=M$, and $Y=Д$.

Thus, $Д-M$ and $X-Y$ changed in the same way with each child leaving the circle, and in the end, $Д-M=X-Y$. This means that in the original circle, $Д-M=X-Y$, which is what we needed to prove.