2. First-grader Petya was laying out a contour of an equilateral triangle with the tokens he had, so that each of its sides, including the vertices, contained the same number of tokens. Then, with the same tokens, he managed to lay out the contour of a square in the same way. How many tokens does Petya have, if each side of the square contains 2 tokens less than each side of the triangle?
Answer: 24.

Solution. Let the side of the triangle contain $x$ chips, and the side of the square - $y$ chips. The total number of chips, counted in two ways, is $3 x-3=4 y-4$ (we account for the corner chips being counted twice). From the problem statement, it follows that $y=x-2$. Therefore, we get the equation $3(x-1)=4(x-3)$, from which $x=9$. Thus, the total number of chips is $3 \cdot 9-3=24$.