#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > MP;
long long n;
pair<long long, int> solve(long long n, int mx) {
  if (n == 0) {
    return make_pair(0, 0);
  }
  if (n < 10) {
    if (mx > n)
      return make_pair(1, n - mx);
    else
      return make_pair(1, 0);
  }
  pair<long long, int> Nw = make_pair(n, mx);
  long long _n = n;
  if (MP.find(Nw) != MP.end()) return MP[Nw];
  long long d = 1;
  for (; d <= n / 10; d *= 10)
    ;
  pair<long long, int> ans = make_pair(0, 0);
  for (;;) {
    int t = n / d;
    pair<long long, int> r = solve(n % d, max(mx, t));
    n -= n % d;
    if (r.second < 0) {
      ans.first += r.first;
      n += r.second;
    } else {
      ans.first += r.first;
      if (max(mx, t)) {
        ans.first++;
        n -= max(mx, t);
      }
    }
    if (!t) break;
  }
  ans.second = n;
  return MP[make_pair(_n, mx)] = ans;
}
int main() {
  scanf("%lld", &n);
  printf("%lld\n", solve(n, 0).first);
  return 0;
}
