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