409190: GYM103451 J Number
Memory Limit:64 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
J. Numbertime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output
Consider some number without leading zeroes(but 0 is allowed). We neee to obtain new number which is divisible by three. In one move we can take any digit of this number and decrease it(if it is not 0) or increase it by 1(if it is not 9). Resulting number should not contain leading zeroes(but 0 is allowed). What is the minimum number of such moves to get a number which is divisible by three?
InputYou are given number n (0 ≤ n ≤ 1018).
OutputOutput answer to the problem.
ExamplesInput12Output
0Input
124Output
1Input
0Output
0Input
123456788Output
1