Time limit
2s
Memory limit
128 MB
You are given a large natural number X. Consider the following transformation on X.
If the final one-digit value is 3, 6, or 9, then the original number X is a multiple of 3. If it is 1, 2, 4, 5, 7, or 8, then X is not a multiple of 3.
Given X, write a program that finds how many transformations are needed to reach a one-digit number and whether X is a multiple of 3.
The first line contains a large natural number X. X has at most 1,000,000 digits and does not start with 0.
On the first line, output the number of transformations performed. This value must be a non-negative integer.
On the second line, output YES if the given number is a multiple of 3, and NO otherwise.
1234567 is transformed as 1234567 -> 28 -> 10 -> 1, so the transformation count is 3 and the number is not a multiple of 3.