Grandpa forgot the four-digit code of his mobile phone. He only remembered that the first digit was not zero, that in the middle were either two fours or two sevens or a four and a seven (in an unknown order), and that the number was divisible by 15. How many possibilities are there for the forgotten code? What digit could be on the first place?

(M. Volfová)

Hint. Start with the middle two-digit number, then consider the other conditions from the problem.
The middle two places can be occupied in exactly four ways:

$$
* 44 *, * 77 *, * 47 *, * 74 * .
$$

A number is divisible by 15 if and only if it is divisible by both three and five. A number is divisible by five if and only if its last digit is either 0 or 5, and a number is divisible by three if and only if the sum of its digits is divisible by three.

If the last digit is 0, then we consider the following options:

$$
* 440, * 770, * 470, * 740
$$

and we look for the first digit such that the sum of the digits is divisible by three. In all cases, the same trio of possibilities emerges: 1, 4, or 7.

If the last digit is 5, then we similarly consider the following options:

$$
* 445, * 775, * 475, * 745 \text {. }
$$

In all cases, the same trio of possibilities emerges: 2, 5, or 8.

The conditions in the problem are satisfied by $4 \cdot 2 \cdot 3=24$ possibilities. The first digit can be any digit except 3, 6, and 9.