#include <bits/stdc++.h>
using namespace std;
long long matn[1000000][10], matop[1000000][10];
int main() {
  long long n, lo = 0, hi = 0, sum = 0;
  cin >> n;
  hi = n / 1000000;
  lo = n % 1000000;
  for (int i = 0; i < 10; i++) {
    matn[0][i] = -i;
    matop[0][i] = (i ? 1 : 0);
  }
  for (int i = 1; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      matn[i][j] = j <= i ? -j : matn[0][j] + i;
      matop[i][j] = j > i || !j ? 1 : 2;
    }
  }
  for (long long i = 10; i < 1000000; i++) {
    long long aux = i, mx = 0;
    while (aux > 0) {
      mx = mx > aux % 10 ? mx : aux % 10;
      aux /= 10;
    }
    for (int j = 0; j < 10; j++) {
      matn[i][j] = matn[min(i - mx, i - j)][j];
      matop[i][j] = matop[min(i - mx, i - j)][j] + 1;
    }
  }
  while (hi > 0) {
    long long aux = hi, mx = 0;
    while (aux > 0) {
      mx = mx > aux % 10 ? mx : aux % 10;
      aux /= 10;
    }
    sum += matop[lo][mx];
    lo = (1000000 + matn[lo][mx]) % 1000000;
    hi--;
  }
  sum += matop[lo][0];
  cout << sum << endl;
  return 0;
}
