#include <bits/stdc++.h>
using namespace std;
long long n;
map<pair<long long, long long>, pair<long long, long long> > mapa;
pair<long long, long long> go(long long x, long long left_max) {
  if (x < 10) return {x > 0 || left_max > 0, x - max(x, left_max)};
  if (mapa.find({x, left_max}) != mapa.end()) return mapa[{x, left_max}];
  long long m = 1;
  while (m <= x / 10) m *= 10;
  pair<long long, long long> a = go(x % m, max(left_max, x / m));
  pair<long long, long long> b = go((x / m) * m + a.second, left_max);
  return mapa[{x, left_max}] = {a.first + b.first, b.second};
}
int main() {
  scanf("%lld", &n);
  printf("%lld\n", go(n, 0).first);
  return 0;
}
