#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int maxn = 1000000;
const double eps = 1e-9;
const double pi = acos(-1.0);
long long n;
int a[maxn + 5][10] = {0}, neg[maxn + 5][10] = {0}, md[maxn + 5] = {0};
int main() {
  int i, j;
  scanf("%I64d", &n);
  for (i = 1; i < maxn + 5; i++) {
    int j = i, r = 0;
    while (j > 0) {
      r = max(r, j % 10);
      j /= 10;
    }
    md[i] = r;
    for (j = 0; j < 10; j++) {
      a[i][j] = a[max(i - max(r, j), 0)][j] + 1;
      if (i < max(r, j))
        neg[i][j] = i - max(r, j);
      else
        neg[i][j] = neg[i - max(r, j)][j];
    }
  }
  int n1 = n / maxn, n2 = n % maxn;
  long long r = 0;
  while (n1 || n2) {
    if (n2 == 0) {
      n2 = maxn - md[n1];
      --n1;
      ++r;
      continue;
    }
    int tt = neg[n2][md[n1]];
    r += a[n2][md[n1]];
    if (tt == 0) {
      n2 = 0;
    } else {
      n2 = maxn + tt;
      --n1;
    }
  }
  printf("%I64d\n", r);
  return 0;
}
