#include <bits/stdc++.h>
using namespace std;
long long step;
map<pair<int, long long>, pair<int, long long> > ji;
int sea(int f, long long v) {
  map<pair<int, long long>, pair<int, long long> >::iterator jii =
      ji.find(make_pair(f, v));
  if (jii != ji.end()) {
    int re = jii->second.first;
    step += jii->second.second;
    return re;
  }
  if (v < 10) {
    if (f > v) {
      step++;
      return f - v;
    }
    if (f == 0) {
      if (v) {
        step++;
      }
      return 0;
    }
    step += 2;
    return f;
  }
  long long c = 1, tmp = v;
  while (tmp >= 10) c *= 10, tmp /= 10;
  int cv = v / c;
  long long nv = v % c;
  long long ss = step;
  while (1) {
    int nx = sea(max(f, cv), nv);
    if (--cv >= 0) {
      nv = c - nx;
    } else {
      ji[make_pair(f, v)] = make_pair(nx, step - ss);
      return nx;
    }
  }
}
int main() {
  long long n;
  scanf("%I64d", &n);
  sea(0, n);
  printf("%I64d\n", step);
  return 0;
}
