#include <bits/stdc++.h>
using namespace std;
long long greatestdigit(long long n) {
  long long max = INT_MIN;
  while (n > 0) {
    if (n % 10 > max) max = n % 10;
    n /= 10;
  }
  return max;
}
int main() {
  long long n, ctr = 0;
  cin >> n;
  if (n == 0) {
    cout << "0" << endl;
    exit(0);
  }
  while (n / 10 > 0) {
    n -= greatestdigit(n);
    ctr++;
  }
  cout << ctr + 1 << endl;
}
