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