#K81377. Final Single Digit

    ID: 35740 Type: Default 1000ms 256MiB

Final Single Digit

Final Single Digit

You are given a non-negative integer \(n\). Your task is to repeatedly sum the digits of \(n\) until a single-digit number is obtained. This process can be formally defined as follows:

Let \(S(n)\) be the sum of the digits of \(n\), then compute: \[ f(n) = \begin{cases} n, & \text{if } n < 10, \\ f(S(n)), & \text{otherwise.} \end{cases} \]

For example, \(f(9875)\) is computed as follows:

\(9+8+7+5=29\) then \(2+9=11\) then \(1+1=2\). So the final answer is 2.

Print the final single-digit number as the output.

inputFormat

The input is read from standard input (stdin) and consists of a single non-negative integer \(n\) in one line.

outputFormat

The output should be the final single-digit number obtained after repeatedly summing the digits of \(n\). The result should be printed to standard output (stdout).

## sample
9875
2

</p>