Problem 2. In a pastry shop, each cake costs 32 denars. On the occasion of September 1st (the start of the school year), the pastry chef announced that every child who enters the pastry shop to buy a cake will receive as much money as they have at that moment before paying. On that day, Damjan entered the pastry shop four times and bought four cakes. In the end, he had no denars left.

How many denars did Damjan have when he first entered the pastry shop?
Solution. First method. If Damjan initially had $x$ denars, then from the condition of the problem we get

$$
2(2(2(2 x-32)-32)-32)-32=0
$$

from which we sequentially obtain

$$
\begin{aligned}
& 2(2(2(2 x-32)-32)-32)-32=0 \\
& 2(2(2 x-32)-32)-32=16 \\
& 2(2 x-32)-32=24 \\
& 2 x-32=28 \\
& 2 x=60
\end{aligned}
$$

Thus, initially Damjan had 30 denars.

Second method. Damjan had 16 denars before the last time he entered the store. This means that before buying the third cake, he had 24 denars (he had 24 denars, the baker gave him 24 denars, and after the purchase, he had $24+24-32=16$ denars left).

To have 24 denars left after buying the second cake, he must have had 28 denars before entering the store (he had 28 denars, the baker gave him 28 denars, so $28+28-32=56-32=24$).

This means that after buying the first cake, he must have had 28 denars. Now it is not difficult to see that he initially had 30 denars (he had 30 denars, the baker gave him 30 denars, and $30+30-32=28$ denars were left).