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