Ajka, Barborka, Cilka, and Danek were arguing about the number of grains of sand on their sandbox. Danek told his friends his estimate, and they decided to verify it. Ajka counted 873451230, Barborka 873451227, and Cilka 873451213 grains. The sum of the (positive) differences between these three results and Danek's estimate was 29.

How many grains of sand could Danek have estimated? List all possibilities. (V. Bachratá)
Cilka counted the least grains, and Ajka counted the most. The difference between Cilka's and Barborka's results is 14, the difference between Barborka's and Ajka's results is 3, and the difference between Cilka's and Ajka's results is 17. If Danek's estimate matched any of these three results, then the mentioned sum of differences would be determined by only two addends:

- If Danek's estimate matched Cilka's result, then the sum of differences from the remaining results would be $14+17=31$.
- If Danek's estimate matched Barborka's result, then the sum of differences from the remaining results would be $14+3=17$.
- If Danek's estimate matched Ajka's result, then the sum of differences from the remaining results would be $17+3=20$.

For other values of Danek's estimate, the following applies:

- If Danek's estimate was less than Cilka's result, then the sum of differences from all results would be greater than 31.
- If Danek's estimate was between Cilka's and Barborka's results, then the sum of differences from all results would be between 31 and 17.
- If Danek's estimate was between Barborka's and Ajka's results, then the sum of differences from all results would be between 17 and 20.
- If Danek's estimate was greater than Ajka's result, then the sum of differences from all results would be greater than 20.

Thus, Danek's estimate could have been between Cilka's and Barborka's results, or greater than Ajka's result. By systematically testing within these constraints, we uncover the following two possibilities:

- If Danek's estimate was 873451215, then the sum of differences from the results of the three friends would be $2+12+15=29$.
- If Danek's estimate was 873451233, then the sum of differences from the results of the three friends would be $20+6+3=29$.

Danek estimated the number of grains in the sandbox to be either 873451215 or 873451233.

Note. For completeness, we add a few more values within the given constraints (in Danek's estimate, we only write the last two digits):

| Danek's estimate | 31 | 31 | 30 | 29 | 28 | 27 | $\ldots$ |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| $\ldots$ | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | $>33$ |
| $\ldots$ | 18 | 17 | 18 | 19 | 20 | 23 | 26 | 29 | $>29$ |

The previous testing can be replaced by a few calculations. For example, assuming Danek's estimate is between Cilka's and Barborka's results, the sum of differences from the results of the three friends is

$$
(d-13)+(27-d)+(30-d)=44-d,
$$

where $d$ is the last two digits of Danek's estimate. This sum equals 29 precisely when $d=15$, which corresponds to one of the mentioned possibilities.