#include <bits/stdc++.h>
using namespace std;
long long X, ans, dp[22][15][15];
int g[22][15][15];
int x[22], i, j, k, l, now;
int calc(int j) {
  int s = 0;
  for (int i = j; i < 19; i++) s = max(s, x[i]);
  return s;
}
int main() {
  scanf("%I64d", &X);
  for (i = 0; i < 19; i++) x[i] = X % 10, X /= 10;
  for (i = 0; i <= 9; i++)
    for (j = 0; j <= 9; j++) {
      if (i == 0)
        dp[1][i][j] = (j > 0), g[1][i][j] = 0;
      else {
        if (j >= i) dp[1][i][j] = 2, g[1][i][j] = 10 - i;
        if (j < i) dp[1][i][j] = 1, g[1][i][j] = 10 + j - i;
      }
    }
  for (i = 2; i <= 18; i++)
    for (j = 0; j <= 9; j++)
      for (k = 0; k <= 9; k++) {
        now = k;
        for (l = 9; l >= 0; l--) {
          dp[i][j][k] += dp[i - 1][max(j, l)][now];
          now = g[i - 1][max(j, l)][now];
        }
        g[i][j][k] = now;
      }
  for (i = 1; i <= 18; i++) {
    for (j = x[i]; j >= 0; j--) {
      now = max(j, calc(i + 1));
      ans += dp[i][now][x[0]];
      x[0] = g[i][now][x[0]];
    }
    if (calc(i + 1) == 0) break;
    if (calc(i + 1) > 0) {
      x[i + 1]--;
      for (j = i + 1; j <= 18; j++)
        if (x[j] >= 0)
          break;
        else
          x[j] += 10, x[j + 1]--;
    }
  }
  printf("%I64d", ans);
  return 0;
}
