#include <bits/stdc++.h>
using namespace std;
long long N;
map<pair<long long, int>, pair<long long, int> > F;
pair<long long, int> dfs(long long x, int y) {
  long long p = 1;
  pair<long long, int> a, b, res;
  if (!x) return res;
  if (x < 10) return make_pair(1, max(y - x, 0ll));
  if (F.count(b = make_pair(x, y))) return F[b];
  for (; p <= x / 10; p *= 10)
    ;
  for (long long t; x > 0;) {
    a = dfs(x % p, t = max(1ll * y, x / p)), res.first += a.first,
    x -= x % p + a.second;
    if (!a.second && t) x -= t, res.first++;
  }
  res.second = -x;
  return F[b] = res;
}
int main() {
  scanf("%I64d", &N);
  printf("%I64d\n", dfs(N, 0).first);
  return 0;
}
