#include <bits/stdc++.h>
using namespace std;
struct O {
  long long x;
  int y;
} f[10][25][10];
long long n, ans;
int a[25], b[25], m;
int main() {
  for (int i = 1; i <= 9; ++i) f[0][0][i] = {1, 0};
  for (int k = 1; k <= 9; ++k)
    for (int i = 0; i <= 9; ++i)
      f[k][0][i] = k <= i ? (O){2, 10 - k} : (O){1, 10 + i - k};
  for (int j = 1; j < 21; ++j)
    for (int k = 0; k <= 9; ++k)
      for (int i = 0; i <= 9; ++i) {
        int x = 9, y = i;
        while (~x) {
          f[k][j][i].x += f[max(k, x)][j - 1][y].x;
          y = f[max(k, x)][j - 1][y].y;
          --x;
        }
        f[k][j][i].y = y;
      }
  scanf("%lld", &n);
  while (n) a[++m] = n % 10, n /= 10;
  for (int i = m; i; --i) {
    b[i] = max(b[i + 1], a[i]);
  }
  for (int i = 2; i <= m; ++i) {
    while (~a[i]) {
      ans += f[max(b[i + 1], a[i])][i - 2][a[1]].x;
      a[1] = f[max(b[i + 1], a[i])][i - 2][a[1]].y;
      --a[i];
    }
    --a[i + 1];
  }
  ans += f[0][0][a[1]].x;
  printf("%lld\n", ans);
  return 0;
}
