Spivak A.V.

If for a number $x$ we calculate the sum of its digits and repeat this process with the resulting number two more times, we will get three more numbers. Find the smallest $x$ for which all four numbers are different, and the last of them is 2.
If $a<b$, then the smallest number with the sum of digits $a$ will be less than the smallest number with the sum of digits $b$.

## Solution

First, let's prove that if $a<b$, then the smallest number with the sum of digits $a$ will be less than the smallest number with the sum of digits $b$. Let $B$ be the smallest number with the sum of digits $b$. If we decrease any non-zero digit of the number $B$ by 1, then the sum of the digits will decrease by exactly 1, and the number itself will also decrease. Therefore, after several (specifically, $b-a$) such operations, we will obtain a number less than $B$ with the sum of digits exactly equal to $a$. Hence, the smallest number with the sum of digits equal to $a$ will be less than $B$. Now we can easily solve the problem. The smallest number with the sum of digits equal to 2 is 11. The smallest number with the sum of digits equal to 11 is 29, and the smallest number with the sum of digits 29 is 2999.

## Answer

2999.