#include <bits/stdc++.h>
std::ofstream fout("out.txt");
long long count = 0;
std::map<std::pair<long long, int>, std::pair<long long, long long>> map;
std::pair<long long, long long> solve(long long n, int max) {
  count++;
  if (n < 10) return {std::max((long long)max, n), 1LL};
  if (map.count({n, max})) return map[{n, max}];
  std::string s = std::to_string(n);
  int digit = s[0] - '0';
  s = s.substr(1);
  std::pair<long long, long long> a =
      solve(std::stoll(s), std::max(digit, max));
  std::pair<long long, long long> b = solve(n - a.first, max);
  b.first += a.first;
  b.second += a.second;
  map[{n, max}] = b;
  return b;
}
int main() {
  long long n;
  std::cin >> n;
  if (n == 0)
    std::cout << 0;
  else
    std::cout << solve(n, 0).second;
  return 0;
}
