#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, pair<long long, long long> > f;
long long n;
pair<long long, long long> solve(long long n, long long Mlc) {
  if (n <= 9) {
    if (n == 0 && Mlc == 0) return {0LL, 0LL};
    if (Mlc == 0) return {1LL, 0LL};
    if (Mlc >= n) return {1LL, n - Mlc};
    return {2LL, -Mlc};
  }
  if (f.count({n, Mlc})) {
    return f[{n, Mlc}];
  }
  long long aux = n;
  long long p = 1LL;
  while (p <= n / 10LL) p *= 10LL;
  pair<long long, long long> q1 = solve(n % p, max(Mlc, n / p));
  n = n - n % p;
  n += q1.second;
  pair<long long, long long> q2 = solve(n, Mlc);
  pair<long long, long long> q = {q1.first + q2.first, q2.second};
  f[{aux, Mlc}] = q;
  return q;
}
int main() {
  scanf("%lld", &n);
  printf("%lld", solve(n, 0).first);
  return 0;
}
