#include <bits/stdc++.h>
using namespace std;
unordered_map<long long, long long> dp;
long long Julya_Calendar(long long n) {
  if (n <= 0) return 0;
  bool f = dp.find(n) != dp.end();
  if (f) {
    return dp[n];
  }
  long long temp = n, ans = LONG_MAX, mod_max = 0;
  while (temp != 0) {
    long long mod = temp % 10;
    mod_max = max(mod_max, mod);
    temp /= 10;
  }
  return dp[n] = 1 + Julya_Calendar(n - mod_max);
}
int main() {
  int n;
  cin >> n;
  cout << Julya_Calendar(n);
  return 0;
}
