#include <bits/stdc++.h>
using namespace std;
int check(int n) {
  int maxx = -1;
  while (n) {
    maxx = (maxx > n % 10 ? maxx : n % 10);
    n /= 10;
  }
  return maxx;
}
int main() {
  int n;
  scanf("%d", &n);
  {
    int sum = 0;
    while (n != 0) {
      n -= check(n);
      sum++;
    }
    printf("%d\n", sum);
  }
}
