Pepík wrote the following problem in his notebook:

$$
M+A+M+R+A+D+M+A+T+E+M+A+T+I+K+U=
$$

Then he replaced the letters with digits from 1 to 9, such that different letters were replaced by different digits and the same letters by the same digits.

What is the largest sum Pepík could have obtained? Could Pepík have obtained a sum of 50?

In one case, Pepík managed to create a sum of 59. Which digit could correspond to the letter $T$ in this case? Determine all possibilities.

(E. Novotná)
In Pepík's expression, there are exactly nine different letters, with the letters $M$ and $A$ repeating four times and the letter $T$ repeating twice. When the letters are replaced by digits according to the given requirements, the sum $M+A+R+D+T+E+I+K+U$ equals the sum of all digits from 1 to 9, which is 45. Therefore, Pepík's sum can be expressed as

$$
4 M+4 A+R+D+2 T+E+I+K+U=3 M+3 A+T+45 .
$$

The largest sum can be obtained by replacing the most frequently occurring letters with the largest possible digits. Thus, the letters $M$ and $A$ should be replaced by the digits 9 and 8 (in any order) and the letter $T$ by the digit 7. The largest sum Pepík could have obtained is

$$
3 \cdot 9+3 \cdot 8+7+45=103 .
$$

The sum of 50 corresponds to such a replacement of letters that $3 M+3 A+T+45=50$, which means $3 M+3 A+T=5$. However, this is not possible, as the mentioned sum is certainly greater than $3+3+1=7$ for any replacement. Pepík could not have obtained the sum of 50.

The sum of 59 corresponds to such a replacement of letters that $3 M+3 A+T+45=59$, which means $3(M+A)+T=14$. The sum $M+A$ is at least $3(=1+2)$ and at most 4 (if $M+A>4$, then $3(M+A)+T>14)$:

- if $M+A=1+2=3$, then $T=14-3 \cdot 3=5$,
- if $M+A=1+3=4$, then $T=14-3 \cdot 4=2$.

In both cases, the letters $M, A$, and $T$ correspond to different digits. When the sum is 59, the letter $T$ could have been replaced by either the digit 5 or 2.

Evaluation. 1 point for the answer to each of the sub-questions; 3 points for completeness and quality of the commentary.