#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, r, largest = 0, ct = 0;
  cin >> a;
  int b = a;
  while (b > 0) {
    while (a > 0) {
      r = a % 10;
      if (largest < r) {
        largest = r;
      }
      a = a / 10;
    }
    ct++;
    b -= largest;
    largest = 0;
    a = b;
  }
  cout << ct;
  return 0;
}
