#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, c;
  char s[1000] = {0};
  scanf("%s", s);
  c = 0;
  while (1) {
    long h;
    h = atol(s);
    long l = strlen(s);
    sort(s, s + l);
    if (h == 0) break;
    h = h - (s[l - 1] - '0');
    sprintf(s, "%ld", h);
    c++;
  }
  cout << c << endl;
  return 0;
}
