#C1875. Academic Number

    ID: 45128 Type: Default 1000ms 256MiB

Academic Number

Academic Number

You are given a non-negative integer n which represents a student ID. Your task is to compute the academic number by repeatedly summing the digits of n until a single digit is obtained.

This can be formulated recursively as follows:

$$S(n)=\begin{cases} n & \text{if } n < 10,\\ S\Big(\sum_{d \in \text{digits}(n)} d\Big) & \text{if } n \geq 10. \end{cases} $$

For example, if n is 9875, the process is:

  • 9 + 8 + 7 + 5 = 29
  • 2 + 9 = 11
  • 1 + 1 = 2

So, the academic number of 9875 is 2.

inputFormat

The input consists of a single line containing a non-negative integer n (0 ≤ n ≤ 1018), representing the student ID.

The input is provided via standard input (stdin).

outputFormat

Output a single digit which is the academic number computed from the input.

The output should be printed to standard output (stdout).

## sample
9875
2

</p>