#include <bits/stdc++.h>
using namespace std;
int max_digit(long long n) {
  int res = -1;
  long long k = n;
  while (k > 0) {
    res = k % 10 > res ? k % 10 : res;
    k /= 10;
  }
  return res;
}
int main() {
  long long n;
  cin >> n;
  int count = 0;
  while (n != 0) {
    int res = max_digit(n);
    n -= res;
    count++;
  }
  cout << count << endl;
  return 0;
}
