Shaovalov A.v.

Let's call a ticket with a number from 000000 to 999999 excellent if the difference between some two adjacent digits of its number is 5.

Find the number of excellent tickets.
Let's calculate the number of non-distinct tickets. As the first digit, we can choose any of the 10 digits. Digits that differ by 5 form pairs: 0-5, 1-6, 2-7, 3-8, 4-9, so when the first digit is chosen, for the second digit in a non-distinct ticket, we can choose any of the 9 digits (excluding the one that pairs with the first). Similarly, after choosing the second digit, for the third digit, we can choose any of the 9 digits, and so on. Therefore, the number of non-distinct tickets is $10 \cdot 9^{2}$.

## Answer

$10^{6}-10 \cdot 9^{5}=409510$ tickets.