#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int strlen(char *);
int main() {
  char x[1000000];
  scanf("%s", x);
  int total = 0, times, count, num;
  for (times = 0; strlen(x) > 1; times++) {
    total = 0;
    for (count = 0; x[count] != '\0'; count++) {
      sscanf(&x[count], "%1d", &num);
      total += num;
    }
    sprintf(x, "%d", total);
  }
  printf("%d", times);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4260,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xf4250(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0xf4254(%rbp)
movl   $0x0,-0xf4258(%rbp)
lea    -0xf4250(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jle    1241 <main+0xf1>
movl   $0x0,-0xf4254(%rbp)
movl   $0x0,-0xf425c(%rbp)
movslq -0xf425c(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1214 <main+0xc4>
movslq -0xf425c(%rbp),%rax
lea    -0xf4250(%rbp),%rdi
add    %rax,%rdi
lea    0xe21(%rip),%rsi
lea    -0xf4260(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0xf4260(%rbp),%eax
add    -0xf4254(%rbp),%eax
mov    %eax,-0xf4254(%rbp)
mov    -0xf425c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf425c(%rbp)
jmp    11b2 <main+0x62>
lea    -0xf4250(%rbp),%rdi
mov    -0xf4254(%rbp),%edx
lea    0xddf(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0xf4258(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4258(%rbp)
jmp    1189 <main+0x39>
mov    -0xf4258(%rbp),%esi
lea    0xdb9(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf4260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf4258,%rsp
lea    0xe98(%rip),%rdi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
xor    %r12d,%r12d
cmp    $0x2,%eax
jl     11ff <main+0xaf>
xor    %r12d,%r12d
lea    0xe74(%rip),%r13
lea    0xc(%rsp),%rbp
jmp    11c2 <main+0x72>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
lea    0xe5d(%rip),%rsi
mov    %ebx,%edx
call   1070 <sprintf@plt>
add    $0x1,%r12d
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jle    11ff <main+0xaf>
cmpb   $0x0,0x10(%rsp)
mov    $0x0,%ebx
je     11a0 <main+0x50>
xor    %ebx,%ebx
mov    %r14,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <sscanf@plt>
add    0xc(%rsp),%ebx
cmpb   $0x0,0x1(%r15)
lea    0x1(%r15),%r15
jne    11e0 <main+0x90>
jmp    11a0 <main+0x50>
lea    0xe01(%rip),%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf4258,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%1d\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000000 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
store i32 0, i32* %3
store i32 0, i32* %4
br label %9
9: ; preds = %36, %0
%10 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %39
13: ; preds = %9
store i32 0, i32* %3
store i32 0, i32* %5
br label %14
14: ; preds = %29, %13
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %14
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 %23
%25 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%26 = load i32, i32* %6
%27 = load i32, i32* %3
%28 = add nsw i32 %27, %26
store i32 %28, i32* %3
br label %29
29: ; preds = %21
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %14
32: ; preds = %14
%33 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 0
%34 = load i32, i32* %3
%35 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %32
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %9
39: ; preds = %9
%40 = load i32, i32* %4
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%1d\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [1000000 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %1, i64 0, i64 0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = bitcast i32* %2 to i8*
%6 = call i32 @strlen(i8* %3)
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %29
8: ; preds = %0, %23
%9 = phi i32 [ %26, %23 ], [ 0, %0 ]
%10 = load i8, i8* %3
%11 = icmp eq i8 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %8, %12
%13 = phi i64 [ %19, %12 ], [ 0, %8 ]
%14 = phi i8* [ %20, %12 ], [ %3, %8 ]
%15 = phi i32 [ %18, %12 ], [ 0, %8 ]
%16 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
%18 = add nsw i32 %17, %15
%19 = add nuw i64 %13, 1
%20 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %12
23: ; preds = %12, %8
%24 = phi i32 [ 0, %8 ], [ %18, %12 ]
%25 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = add nuw nsw i32 %9, 1
%27 = call i32 @strlen(i8* %3)
%28 = icmp sgt i32 %27, 1
br i1 %28, label %8, label %29
29: ; preds = %23, %0
%30 = phi i32 [ 0, %0 ], [ %26, %23 ]
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %30)
ret i32 0
}