Infinite sum of digits

Given an integer n, you are asked to compute the infinite sum of its digits.

We’ll say that the infinite sum of digits is the following process:

  • Compute the sum of digits of n and assign it to n

  • Repeat that process until n is a single-digit number

The input contains a single integer n.

The program should print a single integer - the infinite sum of digits of n.

Input

Output

64

1

8

8

The explanation for 64: 64 → 6 + 4 = 10 → 1 + 0 = 1 ⇒ 1 is the answer

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue