Skip to main content
LIVE CONTEST: ALGOR Contest: Round #4 (Special Challenge) is live now!

~/algor $ cat problems/funksiya-multiplikativ-turgunlik

Digit product steps

Easy 1000 ms 128 MB 31%
Share

Write a function Persistence(x) that returns how many steps it takes for the positive integer $x$ to become a single digit if at each step it is replaced by the product of its digits.

Example 1: Persistence(39) → 3 — $39 \to 27 \to 14 \to 4$, $3$ steps.

Example 2: Persistence(7) → 0 — the number already has one digit, no steps are needed.

Write only the function body.

The number is replaced by the product of its digits, the function returns the number of steps

Input

One line with a positive integer $x$ — the argument of the function.

Output

The value returned by the function: an integer.

Note

$1 \le x \le 10^{15}$

Examples

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

Sign in to submit a solution

Signing up is free and takes a minute.