CPython lite logoProblemsContests

20. Digital Root

Calculate the digital root of the given number. The digital root is defined by the following expression:

DigitalRoot(x)={xif x < 10DigitalRoot(SumOfDigits(x))otherwise


Input

On the first line, a natural number n(1n1030).

Output

The solution to the problem in a single line.


Sample input 1

8

Sample output 1

8

Sample input 2

11

Sample output 2

2

Sample input 3

173

Sample output 3

2

Login to be able to submit.

MediumMathLoops
387 / 33
Solved / unsolved count
1.0 s / 512 MB
Limits