#include <bits/stdc++.h>
using namespace std;
long long s[20][10][10][10] = {0};
int to[20][10][10][10] = {0};
struct CP {
  int gap, q, i, j;
  long long ans;
};
void Subtract(int c[20], int& cn, int k) {
  int i = 0;
  c[0] -= k;
  while (c[i] < 0) {
    c[i] += 10;
    --c[i + 1];
    ++i;
  }
  if (i == cn - 1 && c[i] == 0) {
    --cn;
  }
}
int main() {
  long long n;
  scanf("%I64d", &n);
  memset(s, -1, sizeof(s));
  memset(to, -1, sizeof(to));
  long long ans = 0;
  int c[20] = {0};
  int cn = 0;
  for (long long t = n; t > 0; t /= 10) {
    c[cn++] = t % 10;
  }
  stack<CP> cps;
  while (cn > 1) {
    int i = 1;
    int last = c[0];
    while (c[i] == 0) {
      ++i;
    }
    int second = c[i];
    int gap = i;
    ++i;
    int q = 0;
    while (i < cn) {
      if (c[i] > q) q = c[i];
      ++i;
    }
    while (!cps.empty()) {
      const CP& cp = cps.top();
      if ((gap == cp.gap && second == cp.i - 1) ||
          (gap > cp.gap && cp.i == 1)) {
        s[cp.gap][cp.q][cp.i][cp.j] = ans - cp.ans;
        to[cp.gap][cp.q][cp.i][cp.j] = last;
        cps.pop();
      } else {
        break;
      }
    }
    if (s[gap][q][second][last] != -1) {
      ans += s[gap][q][second][last];
      --c[gap];
      c[0] = to[gap][q][second][last];
    } else {
      CP cp;
      cp.ans = ans;
      cp.gap = gap;
      cp.i = second;
      cp.j = last;
      cp.q = q;
      cps.push(cp);
      Subtract(c, cn, max(max(q, second), last));
      ++ans;
    }
  }
  if (cn > 0 && c[0] != 0) {
    ++ans;
  }
  printf("%I64d\n", ans);
  return 0;
}
