#include <bits/stdc++.h>
using namespace std;
int bigdigit[1000000 + 5];
int dp[10][1000000 + 5], trc[10][1000000 + 5];
void input() {
  long long n;
  int i, j;
  scanf("%I64d", &n);
  for ((i) = (0); (i) <= (1000000); (i)++) {
    int xmax = 0, t = i;
    while (t) xmax = ((xmax) > (t % 10) ? (xmax) : (t % 10)), t /= 10;
    bigdigit[i] = xmax;
  }
  dp[0][0] = 0;
  trc[0][0] = 0;
  for ((i) = 0; (i) < (10); (i)++)
    for (j = i == 0 ? 1 : 0; j < 1000000; j++) {
      int next = j - ((i) > (bigdigit[j]) ? (i) : (bigdigit[j]));
      if (next < 0) {
        dp[i][j] = 1;
        trc[i][j] = next;
      } else {
        dp[i][j] = dp[i][next] + 1;
        trc[i][j] = trc[i][next];
      }
    }
  long long res = 0;
  int part1 = n / 1000000;
  int part2 = n % 1000000;
  while (part1 >= 0) {
    int xmax = bigdigit[part1];
    res += dp[xmax][part2];
    part2 = 1000000 + trc[xmax][part2];
    part1--;
  }
  printf("%I64d", res);
}
int main() {
  input();
  return 0;
}
