#include <bits/stdc++.h>
using namespace std;
long long n;
map<pair<long long, long long>, pair<long long, long long> > M;
pair<long long, long long> Get(long long n, int mx) {
  if (n <= 0ll) return pair<long long, long long>(0ll, n);
  pair<long long, long long> p = pair<long long, long long>(n, mx);
  if (!M.count(p)) {
    long long a = 1;
    while (a <= n / 10ll) a *= 10ll;
    int dig = n / a;
    pair<long long, long long> res = pair<long long, long long>(0ll, n % a);
    while (dig > 0 || res.second > 0) {
      pair<long long, long long> tmp = Get(res.second, max(mx, dig));
      res.first += tmp.first;
      res.second = tmp.second;
      if (dig > 0 && res.second == 0) {
        res.first++;
        res.second -= max(mx, dig);
      }
      if (dig > 0 && res.second != 0) {
        dig--;
        res.second += a;
      }
    }
    M[p] = res;
  }
  return M[p];
}
int main() {
  scanf("%I64d", &n);
  printf("%I64d\n", Get(n, 0).first);
  return 0;
}
