#K69067. Digit Root Calculation

    ID: 33004 Type: Default 1000ms 256MiB

Digit Root Calculation

Digit Root Calculation

Given a non-negative integer ( n ), the task is to calculate its digit root. The digit root is obtained by repeatedly summing the digits of ( n ) until a single digit is obtained. A mathematical formula to obtain the digit root for ( n > 0 ) is given by

dr(n)=1+((n1)mod9)dr(n)=1+((n-1)\mod 9)

and if ( n = 0 ) then the digit root is 0.

Your program should read the integer from standard input and output its digit root to standard output.

inputFormat

The input consists of a single line containing a non-negative integer ( n ).

outputFormat

Output a single integer, which is the digit root of the input integer.## sample

9875
2