2. First-grader Petya was laying out a contour of an equilateral triangle with the chips he had, so that each of its sides, including the vertices, contained the same number of chips. Then, with the same chips, he managed to lay out the contour of a square in the same way. How many chips does Petya have, if each side of the square contains 2 chips 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$.