#include <iostream>
#include <cstring>
using namespace std;
int f(char* str, int i) {
if (i == 0)
return int(str[i]) - int('0');
else
return (int(str[i]) - int('0')) * f(str, i - 1);
}
int main() {
char str[10];
int t;
while (cin >> str) {
int count = 0;
while (strlen(str) > 1) {
int k = strlen(str) - 1;
t = f(str, k);
memset(str, 0, sizeof(str) / sizeof(str[0]));
sprintf(str, "%d", t);
count++;
}
cout << count << endl;
}
return 0;
}