#include <bits/stdc++.h>
using namespace std;
struct hf {
  size_t operator()(const pair<long long, long long> &a) const {
    return a.first * 49 + a.second;
  }
};
long long tens[18] = {1ll};
unordered_map<pair<long long, long long>, pair<long long, long long>, hf>
    faster;
pair<long long, long long> ansof(long long now, long long lastmax) {
  if (now < 10ll) return {0, now};
  pair<long long, long long> tmp = {now, lastmax};
  auto fit = faster.find(tmp);
  if (fit != faster.end()) return fit->second;
  long long lim = *(upper_bound(tens, tens + 18, now) - 1);
  long long firstdig = now / lim;
  long long op = 0;
  pair<long long, long long> clearback;
  while (firstdig > 0) {
    long long nowmax = max(lastmax, firstdig);
    clearback = ansof(now % lim, nowmax);
    now = firstdig * lim;
    op += clearback.first;
    if (clearback.second >= nowmax) {
      op += 2;
      now -= nowmax;
    } else {
      ++op;
      now -= nowmax - clearback.second;
    }
    --firstdig;
  }
  clearback = ansof(now % lim, lastmax);
  return faster[tmp] = {clearback.first + op, clearback.second};
}
int main() {
  faster.reserve(1300400);
  for (int i = 1; i < 18; ++i) tens[i] = tens[i - 1] * 10ll;
  long long n;
  cin >> n;
  pair<long long, long long> ans = ansof(n, 0);
  cout << ((ans.second == 0) ? ans.first : ans.first + 1) << '\n';
}
