Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/while-raqamli-ildiz

Digital root

Medium 1000 ms 64 MB 46%
Share

A positive integer $n$ is given. The sum of its digits is computed; if the result has more than one digit, the sum of its digits is computed, and so on until a one-digit number is obtained. That one-digit number is called the digital root of $n$. Find the digital root and how many times the digit sum was computed (if $n$ itself has one digit, the second number is $0$; for example, $9875 \to 29 \to 11 \to 2$ — the digital root is $2$, the sum was computed $3$ times).

A chain of successive digit sums until one digit remains

Input

One positive integer $n$.

Output

One line with two integers separated by a space: the digital root and the number of computations.

Note

$1 \le n \le 10^{18}$

Examples

Input #1
9875
Output #1
2 3
Input #2
7
Output #2
7 0

Sign in to submit a solution

Signing up is free and takes a minute.