#include <bits/stdc++.h>
using namespace std;
long long Naive(long long n) {
  if (!n) {
    return 0;
  }
  long long mx = 0, nn = n;
  while (nn) {
    mx = max(mx, nn % 10);
    nn /= 10;
  }
  return Naive(n - mx) + 1;
}
map<pair<long long, long long>, pair<long long, long long>> M;
pair<long long, long long> Solve(long long n, long long mn = 0) {
  if (M.count(make_pair(n, mn)) != 0) {
    return M[make_pair(n, mn)];
  }
  if (n <= 0) {
    return make_pair(0, -n);
  }
  long long nn = n;
  long long mx = 1000000000000000000LL;
  long long ret = 0;
  for (int i = 0; i < 19; ++i) {
    if (n / mx > 0) {
      while (n / mx > 0) {
        pair<long long, int> par = Solve(n % mx, max(mn, n / mx));
        ret += par.first;
        n -= n % mx + par.second;
        if (par.second == 0) {
          ++ret;
          n -= max(mn, n / mx);
        }
      }
    }
    mx /= 10;
  }
  if (n < 0) {
    n = -n;
  }
  return M[make_pair(nn, mn)] = make_pair(ret, n);
}
int main() {
  long long n;
  cin >> n;
  cout << Solve(n).first << endl;
  return 0;
}
