#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1100000;
long long cnt[20][10][10];
long long to[20][10][10];
int getmax(long long n) {
  long long res = 0;
  while (n) {
    res = max(res, n % 10);
    n /= 10;
  }
  return res;
}
long long solve(long long x) {
  if (x == 0) return 0;
  long long ans = 0;
  long long cur = x % 10;
  for (int i = 0; x != -1; i++) {
    x /= 10;
    while ((x + 10) % 10 != 9) {
      ans += cnt[i][cur][getmax(x)];
      cur = to[i][cur][getmax(x)];
      x--;
    }
  }
  ans--;
  return ans;
}
int main() {
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      if (j > i)
        cnt[0][i][j] = 1, to[0][i][j] = (i - j + 10) % 10;
      else
        cnt[0][i][j] = 2, to[0][i][j] = (10 - j);
  for (int k = 1; k < 20; k++) {
    for (int x = 0; x < 10; x++)
      for (int j = 0; j < 10; j++) {
        cnt[k][x][j] = 0;
        to[k][x][j] = x;
        for (int f = 9; f >= 0; f--) {
          cnt[k][x][j] += cnt[k - 1][to[k][x][j]][max(j, f)];
          to[k][x][j] = to[k - 1][to[k][x][j]][max(j, f)];
          assert(to[k][x][j] != 0);
        }
      }
  }
  long long n;
  scanf("%lld", &n);
  printf(
      "%lld"
      "\n",
      solve(n));
  ;
  return 0;
}
