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