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