## Task B-3.5.

Marko is trying to remember one of his passwords. He remembers that it is a five-digit number with different digits, where the first and last digit differ by 4, and the sequence of the remaining three digits in the middle forms a two-digit or three-digit number divisible by 5. If Marko were to start listing all such numbers, how many numbers could he list at most to find his password? The first digit of the password is not zero.
## First Solution.

We are looking for the total number of five-digit numbers $\overline{x a b c y}$ that have the desired properties (where $x, y, a, b, c \in\{0,1,2,3,4,5,6,7,8,9\}$ and $x \neq 0$).

There are eleven different possibilities for choosing the first and last digits:

$(x, y) \in\{(1,5),(5,1),(4,0),(5,9),(9,5),(2,6),(6,2),(3,7),(7,3),(4,8),(8,4)\}$.

If $\overline{a b c}$ is a two-digit or three-digit number divisible by $5$, then $c \in\{0,5\}$.

Since all digits of the given number are different, we can distinguish two cases.
$1^{\circ}$ At least one of the first or last digits is equal to 0 or 5.

Then the fourth digit $c$ is uniquely determined, so

$(x, y, c) \in\{(1,5,0),(5,1,0),(4,0,5),(5,9,0),(9,5,0)\}$.

1 point

For each of these five choices of digits $x, y, c$, we have 7 ways to choose the second digit $a$ (they cannot be the already chosen $x, y, c$), and 6 ways to choose the third digit $b$. This gives a total of $5 \cdot 6 \cdot 7=210$ different five-digit numbers.

$2^{\circ}$ The first and last digits are different from 0 and 5.

Then $(x, y) \in\{(2,6),(6,2),(3,7),(7,3),(4,8),(8,4)\}$.

We can choose the digit $c$ in two ways (0 or 5), the digit $a$ in 7 ways, and the digit $b$ in 6 ways, which gives a total of 6・2$\cdot$7$\cdot$6 $=504$ different five-digit numbers.

In total, we have $210+504=714$ ways to choose five-digit numbers with the desired properties.