#include <bits/stdc++.h>
using namespace std;
short find_max(long long unsigned int magic) {
  short current;
  short max = 0;
  while (1) {
    current = magic % 10;
    magic /= 10;
    if (max < current) max = current;
    if (magic == 0) break;
  }
  return max;
}
int main() {
  short max;
  int count = 0;
  long long unsigned int magic;
  cin >> magic;
  while (magic != 0) {
    max = find_max(magic);
    magic -= max;
    count++;
  }
  cout << count << endl;
}
