Олимпиадный тренинг

Задача 38497. A multiple of three


Задача

Темы:
Given a number. In this number, it is necessary to change one digit in such a way that the new number is divisible by 3 and would be the maximum possible. In the original number you need
it is obligatory to change one digit, even if the original number has already been divided by 3. The program receives one long natural number as input. Number length can
reach 100 digits.
The program should output another natural number that satisfies the conditions:
1. The new number must differ from the given one by exactly one digit.
2. The new number must be divisible by 3.
3. The new number must be the maximum possible of all such numbers.
Examples
# Input Output
1 123 723