#include <bits/stdc++.h>
using namespace std;
int n, i, j, k;
int u, v, w;
long long f[20][10][10], ans = 0;
int g[20][10][10];
int mx[20];
char s[20];
int main() {
  scanf("%s", s);
  n = strlen(s);
  if (n == 1) {
    putchar(48 | (s[0] > 48));
    putchar(10);
    return 0;
  }
  for (j = 1; j < 10; ++j) {
    for (k = 0; k < j; ++k) {
      f[0][j][k] = 1;
      g[0][j][k] = 10 + k - j;
    }
    for (k = j; k < 10; ++k) {
      f[0][j][k] = 2;
      g[0][j][k] = 10 - j;
    }
  }
  for (k = 0; k < 10; ++k) {
    f[0][0][k] = 1;
    g[0][0][k] = 0;
  }
  for (i = 1; i < n; ++i)
    for (j = 0; j < 10; ++j)
      for (k = 0; k < 10; ++k) {
        long long &res = f[i][j][k];
        v = k;
        for (u = 9; ~u; --u) {
          w = max(u, j);
          res += f[i - 1][w][v];
          v = g[i - 1][w][v];
        }
        g[i][j][k] = v;
      }
  for (i = 0; i < n; ++i) s[i] &= 15;
  v = s[n - 1];
  for (i = n - 2; ~i;) {
    j = 0;
    for (k = 0; k < i; ++k) j = max(j, (int)s[k]);
    for (u = s[i]; ~u; --u) {
      w = max(u, j);
      ans += f[n - i - 2][w][v];
      v = g[n - i - 2][w][v];
    }
    s[i] = 9;
    --s[--i];
    for (; ~i && s[i] == -1; s[i] = 9, --s[--i])
      ;
  }
  printf("%lld\n", ans);
}
