#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
map<std::pair<long long, int>, std::pair<long long, int> > M;
std::pair<long long, int> get(long long v, int mx) {
  if (v == 0) return std::pair<long long, int>(0LL, 0);
  if (v < 10) {
    std::pair<long long, int> ans = std::pair<long long, int>(1LL, 0);
    if (v < mx) ans.second = mx - v;
    return ans;
  }
  std::pair<long long, int> cur = std::pair<long long, int>(v, mx);
  if (M.find(cur) != M.end()) return M[cur];
  long long step = 1;
  while (step <= v / 10) step *= 10;
  std::pair<long long, int> ans = std::pair<long long, int>(0LL, 0);
  int dig, newmx;
  while (true) {
    dig = v / step;
    newmx = mx;
    if (dig > newmx) newmx = dig;
    std::pair<long long, int> c = get(v % step, newmx);
    ans.first += c.first;
    v -= v % step;
    if (c.second > 0)
      v -= c.second;
    else {
      v -= newmx;
      if (newmx > 0) ++ans.first;
    }
    if (dig == 0) break;
  }
  ans.second = -v;
  M[cur] = ans;
  return ans;
}
long long n;
int main() {
  scanf("%I64d", &n);
  M.clear();
  std::pair<long long, int> res = get(n, 0);
  printf("%I64d\n", res.first);
  return 0;
}
