#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > d;
long long n, ans;
pair<long long, int> rec(long long n, int md) {
  if (n == 0) return make_pair(0, 0);
  if (n < md) {
    return make_pair(0, n);
  }
  pair<long long, int> st = make_pair(n, md);
  if (d.find(st) != d.end()) return d[st];
  pair<long long, int> res = make_pair(0, 0);
  long long s = 1;
  while (s <= n / 10) s *= 10;
  while (true) {
    int nmd = md;
    nmd = max(nmd, (int)(n / s));
    pair<long long, int> t = rec(n % s, nmd);
    res.second = t.second;
    res.first += t.first;
    if (n < s) break;
    n = n / s * s + t.second;
    res.first += 1;
    n -= nmd;
  }
  d[st] = res;
  return res;
}
void solve() { ans = rec(n, 0).first; }
int main() {
  scanf("%lld", &n);
  solve();
  printf("%lld\n", ans);
  return 0;
}
