In a fairy tale valley, three-headed and six-headed dragons lived. Together they had 117 heads and 108 legs. Each dragon has 4 legs. Find out how many three-headed and how many six-headed dragons lived there.
Since every dragon (both three-headed and six-headed) has 4 legs, we can find the total number of dragons in the fairy tale valley: $108: 4=27$ dragons. If every dragon in the valley had three heads, they would have a total of $3 \cdot 27=81$ heads. This means that the remaining $117-81=36$ heads are the extra heads that six-headed dragons have compared to three-headed dragons. Since a six-headed dragon has three more heads than a three-headed dragon, there are $36: 3=12$ six-headed dragons living in this valley. The number of three-headed dragons is $27-12=15$.

number of all dragons - $2 b$

number of three-headed dragons - $3 b$

number of six-headed dragons - $1 b$