#include <bits/stdc++.h>
using namespace std;
int main() {
  long long val;
  cin >> val;
  int count = 0;
  while (val) {
    long long temp = val;
    long long maxx = 0;
    while (temp) {
      long long dig = temp % 10;
      maxx = (dig > maxx ? dig : maxx);
      temp /= 10;
    }
    val -= maxx;
    ++count;
  }
  cout << count << endl;
}
