2. Petya came up with a four-digit number, in which all the digits are different. It is known that the sum of the first three digits of this number is divisible by 9 and the sum of the last three digits of this number is divisible by 9. What values can the sum of all the digits of this number take? Find all possible values and explain why there are no others.
2. Answer. The sum of the digits is 18.

According to the condition, the sum of the first three digits is divisible by 9, and the sum of the last three is also divisible by 9. Therefore, the difference between the first and the last digit is divisible by 9. Since all digits are different, the first digit is 9, and the last digit is zero. Since the sum of the last three digits is divisible by 9, and the last digit is 0, the sum of the two middle digits is also divisible by 9. Since the middle digits are both less than 9 and greater than 0, their sum is less than 18 but greater than zero (and divisible by 9). Therefore, the sum of the two middle digits is 9, and the sum of all the digits of this number is 18.