#include <bits/stdc++.h>
using namespace std;
long long mx[1100000], ans[10][1100000], dig[10][1100000], temp, par, aa, lst,
    fst, n;
long gmx(long long x) {
  long long r = 0;
  while (x) {
    r = max(r, x % 10);
    x /= 10;
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(0);
  for (long long i = 0; i <= 1000000; i++) {
    long long q = i;
    mx[i] = 0;
    while (q) {
      mx[i] = max(mx[i], q % 10);
      q /= 10;
    }
  }
  for (long long pref = 0; pref <= 9; pref++) {
    for (long long suf = 0; suf <= 1000000; suf++) {
      temp = max(pref, mx[suf]);
      par = suf - temp;
      if (par < 0) {
        ans[pref][suf] = 1;
        dig[pref][suf] = par;
      } else {
        ans[pref][suf] = ans[pref][par] + 1;
        dig[pref][suf] = dig[pref][par];
      }
    }
  }
  cin >> n;
  lst = n % 1000000;
  fst = n / 1000000;
  while (fst >= 0) {
    aa += ans[mx[fst]][lst];
    lst = 1000000 + dig[mx[fst]][lst];
    fst--;
  }
  cout << aa - 1 << endl;
  cin.get();
  cin.get();
  return 0;
}
