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