The digital root of a number

Given an integer n, we can compute the digital root of n by summing up all the digits of n and repeating that process on the result until reaching a single digit. The digital sum of a number is the result of an iterative process of summing the digits of the number. You are asked to write a program that would calculate the digital root of a number.

Input

The input contains a single integer n (0 ≤ n ≤ ).

Output

The program should print the digital root of the number n.

Examples

Input
Output
15
6
12345
6

Explanation

  1. 15 → 1 + 5 = 6
  1. 12345 → 1 + 2 + 3 + 4 + 5 = 15 → 1 + 5 = 6
 

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