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