#include using namespace std; typedef long long ll; ll toInt(string s, ll b = 10) { assert(b > 1); ll res = 0; for (char c : s) { res *= b; res += c - '0'; } return res; } string toStr(ll x, ll b = 10) { assert(b > 1 && x >= 0); if (x == 0) return "0"; string res; while (x) { res += (x % b) + '0'; x /= b; } reverse(res.begin(), res.end()); return res; } int main() { ll n; cin >> n; map memo; auto f = [&](auto self, ll x) -> ll { if (x < 10) return 0; if (memo.count(x)) return memo[x]; string s = toStr(x); ll next = 1; for (auto c : s) { next *= int(c - '0'); } ll res = 1 + self(self, next); memo[x] = res; return res; }; cout << f(f, n) << endl; return 0; }