问题10101--数字魔法

10101: 数字魔法

[命题人 : ]
时间限制 : 2.000 sec  内存限制 : 256 MiB

题目描述

【题目描述】

在看完最后一部哈利波特电影后,小杰拉尔德也决定练习魔法。他在父亲的魔法书里发现了一个咒语,可以将任何数字相加。就在杰拉尔德知道这一点的那一刻,他遇到了一个数字n。杰拉尔德可以对它施多少次咒语,直到这个数字变成一位数?

【输入】

第一行包含唯一的整数n(0n10100000)。它保证n不包含任何前导零。

【输出】

输出一个数字可以被其数字之和替换的次数,直到它只包含一个数字。

【输入】

0

【输出】

0

【输入】

10

【输出】

1

【输入】

991

【输出】

3

【说明】

在第一个例子中,数字已经是一位数-先驱不能施法。

第二个测试包含数字10。施放一次法术后,它就变成了1,这个过程就完成了。因此,杰拉德只能施一次咒语。

第三个测试包含编号991。当一个人施咒时,会发生以下变化:99119101。经过三次变换,这个数字变成了一位数。

样例输入 复制


样例输出 复制


提示

Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-digit?
Input
The first line contains the only integer n (0≤n≤10100000). It is guaranteed that n doesn't contain any leading zeroes.
Output
Print the number of times a number can be replaced by the sum of its digits until it only contains one digit.
Examples
Input
0
Output
0
Input
10
Output
1
Input
991
Output
3
Note
In the first sample the number already is one-digit − Herald can't cast a spell.
The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.
The third test contains number 991. As one casts a spell the following transformations take place: 991→19→10→1. After three transformations the number becomes one-digit

来源/分类