#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long mat[10][10];
int m;
unsigned long long n;
mat f[22][10], ans, t;
void reset(mat a) {
  for (int l = 0; l < 10; l++)
    for (int r = 0; r < 10; r++) a[l][r] = l == r ? 0 : n;
}
void renew(mat a, mat b) {
  for (int l = 0; l < 10; l++)
    for (int r = 0; r < 10; r++) {
      t[l][r] = n;
      for (int o = 0; o < 10; o++)
        if (a[l][o] < n && b[o][r] < n)
          t[l][r] = min(t[l][r], a[l][o] + b[o][r]);
    }
  memcpy(a, t, sizeof(t));
}
int main() {
  scanf("%I64u", &n);
  int tt = n % 10;
  n = (n / 10 + 1) * 10 + 1;
  unsigned long long tmp = 1;
  for (; tmp <= n; tmp *= 10, m++)
    ;
  for (int j = 0; j < 10; j++)
    for (int l = 0; l < 10; l++)
      for (int r = 0; r < 10; r++) {
        if (j <= r)
          if (r)
            f[1][j][l][r] = f[1][j][l][0] + 1;
          else
            f[1][j][l][r] = 0;
        else if (10 + r - j == l)
          f[1][j][l][r] = 1;
        else
          f[1][j][l][r] = n;
      }
  for (int i = 2; i <= m; i++)
    for (int j = 0; j < 10; j++) {
      reset(f[i][j]);
      for (int k = 0; k < 10; k++) renew(f[i][j], f[i - 1][max(j, k)]);
    }
  int j = 0;
  reset(ans);
  for (int i = m - 1; i >= 1; i--) {
    tmp /= 10;
    for (int k = 0; k < n / tmp % 10; k++) renew(ans, f[i][max(j, k)]);
    j = max(j, int(n / tmp % 10));
  }
  printf("%I64u\n", ans[0][tt]);
}
