#include <bits/stdc++.h>
using namespace std;
const int sz = (int)(1e6 + 1);
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string n;
  int steps = 0;
  cin >> n;
  while (stoi(n) > 0) {
    int mx = std::numeric_limits<int>::min();
    for (int i = 0; i < n.size(); i++) {
      char c = n[i];
      int converted = c - 48;
      if (converted > mx) {
        mx = converted;
      }
    }
    int j = stoi(n) - mx;
    n = to_string(j);
    steps++;
  }
  cout << steps << endl;
}
