#include <bits/stdc++.h>
int max, n, i;
int enBuyuk(int x) {
  max = 0;
  while (x) {
    int a = x % 10;
    if (a > max) max = a;
    x /= 10;
  }
  return max;
}
int main() {
  scanf("%d", &n);
  int s = 0;
  while (n > 0) {
    n -= enBuyuk(n);
    s++;
  }
  printf("%d", s);
  return 0;
}
