#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  long long int max = 0, steps = 0;
  while (atoi(str.c_str()) != 0) {
    for (int i = 0; i < str.length(); i++) {
      if ((int)str[i] - 48 > max) max = (int)str[i] - 48;
    }
    str = to_string(atoi(str.c_str()) - max);
    steps++;
    max = 0;
  }
  cout << steps << endl;
  return 0;
}
