Filoména has a mobile phone with the following button layout:

| 1 | 2 | 3 |
| :--- | :--- | :--- |
| 4 | 5 | 6 |
| 7 | 8 | 9 |
| 0 |  |  |
|  |  |  |
|  |  |  |

The nine-digit phone number of her best friend Kunhuta has the following properties:

- all digits in Kunhuta's phone number are different,
- the first four digits are arranged in ascending order from smallest to largest, and the centers of their buttons form a square,
- the centers of the buttons of the last four digits also form a square,
- the phone number is divisible by three and five.

How many different nine-digit numbers could be Kunhuta's phone number?

(K. Pazourek)

Idea. Which digits can form the last and which the first quartet?
First, let's find all quadruples of buttons whose centers form a square. These are the buttons with the following digits:

$$
\begin{array}{ll}
1,2,4,5 & 1,3,7,9 \\
2,3,5,6 & 2,4,6,8 \\
4,5,7,8 & 5,7,9,0 \\
5,6,8,9 &
\end{array}
$$

The quadruples in the left column, however, cannot be used because, besides the square formed by the relevant buttons, we cannot form another square with the remaining buttons. Since the phone number is divisible by five, it must end in 5 or 0; therefore, the last four digits of the phone number are 5, 7, 9, 0 (their order will be discussed later). Since we have already used the digits 7 and 9, the first four digits of the phone number must be 2, 4, 6, 8 (in this order, they are arranged by size).

The digits that have not yet been used and can be in the middle of the phone number are 1 and 3. The phone number must be divisible by three, so let's determine the possible digit sums. The sum of all digits on the keypad is 45. If the phone number contains 1, i.e., the phone number includes all digits except 3, the digit sum would be $45-3=42$. If the phone number contains 3, the digit sum would be $45-1=44$. The number 42 is divisible by 3, while 44 is not; therefore, the middle digit is 1.

Since we have not overlooked any of the requirements in the problem, the sought phone number is

$$
24681 * * * *
$$

where the last four digits are $5,7,9,0$ in an unknown order, but we know that the last digit must be 5 or 0. To determine the number of all possible Kunhut's phone numbers, we will not list them all but use this idea: The last digit can be chosen in two ways, the second-to-last digit can then be chosen from the three remaining digits, the preceding one from the two remaining, and the last unfilled position will always have one remaining digit. Altogether, we get

$$
2 \cdot 3 \cdot 2=12
$$

possible orders for the last four digits, and thus 12 possible Kunhut's phone numbers.