#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> in{999999, 1000000};
  for (auto i : in) {
    int a = i, cnt = 0;
    ;
    string s{};
    while (a >= 10) {
      auto enum_int = [&] {
        s = to_string(a);
        vector<pair<string, string> > xs;
        for (int i = 1; i < s.size(); i++) {
          xs.push_back(std::make_pair(s.substr(0, i), s.substr(i)));
        }
        return xs;
      };
      auto&& xs = enum_int();
      int m = 0;
      for (auto& x : xs) {
        m = max(m, std::stoi(x.first) * std::stoi(x.second));
      }
      a = m;
      cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}
