#include <bits/stdc++.h>
#pragma GCC optimization("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
using namespace std;
const int BASE = 1000000;
char what[1 << 20];
pair<int, int> nxt[10][1 << 20];
inline long long Calc(long long x) {
  long long suff = x / BASE, pref = x % BASE;
  long long ans = suff;
  while (suff > 0) {
    ans += nxt[what[suff]][pref].first;
    pref = nxt[what[suff]][pref].second;
    pref += BASE - max(what[suff], what[pref]);
    --suff;
  }
  return ans + nxt[0][pref].first;
}
int main() {
  for (int i = 1; i <= BASE; ++i) {
    int val = 0;
    for (int x = i; x > 0; x /= 10) {
      val = max(val, x % 10);
    }
    what[i] = val;
    for (int d = 0; d < 10; ++d) {
      if (i >= max(d, val)) {
        nxt[d][i] = make_pair(nxt[d][i - max(d, val)].first + 1,
                              nxt[d][i - max(d, val)].second);
      } else {
        nxt[d][i] = make_pair(0, i);
      }
    }
  }
  long long n;
  cin >> n;
  cout << Calc(n) << '\n';
  return 0;
}
