#include <bits/stdc++.h>
using namespace std;
int H[10][1000005], cnt[10][1000005];
int find(int x, int n) {
  if (n <= 0) return 0;
  if (cnt[x][n] != -1) return cnt[x][n];
  int y = 0, k = 0, tmp = n;
  while (tmp) {
    y = max(y, tmp % 10);
    tmp /= 10;
  }
  y = max(x, y);
  cnt[x][n] = find(x, n - y) + 1;
  if (n <= y)
    H[x][n] = y;
  else
    H[x][n] = H[x][n - y] + y;
  return cnt[x][n];
}
int main() {
  long long n, tmp, rlt = 0;
  int a[20], k, i, x;
  memset(cnt, -1, sizeof(cnt));
  cin >> n;
  while (n) {
    k = 0;
    tmp = n;
    while (tmp) {
      a[k++] = tmp % 10;
      tmp /= 10;
    }
    x = 0;
    if (n % 1000000 == 0) {
      for (i = 0; i < k; i++) x = max(x, a[i]);
      rlt++;
      n -= x;
      continue;
    }
    for (i = 6; i < k; i++) x = max(x, a[i]);
    rlt += find(x, n % 1000000);
    n -= H[x][n % 1000000];
  }
  cout << rlt << endl;
}
