#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, pair<long long, long long> > f;
long long n;
inline long long read() {
  long long x = 0, c = getchar(), f = 1;
  while (c < '0' || c > '9') f = (c == '-' ? -f : f), c = getchar();
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - 48, c = getchar();
  return f > 0 ? x : -x;
}
void print(int x) {
  if (x > 9LL) print(x / 10LL);
  putchar(x % 10 + 48);
}
pair<long long, long long> find(long long x, long long y) {
  if (y < 10) return pair<long long, long long>(1, max(x, y) - y);
  if (f.count(pair<long long, long long>(x, y)))
    return f[pair<long long, long long>(x, y)];
  long long t = 1;
  while (10 * t <= y) t = 10 * t;
  pair<long long, long long> A = find(max(x, y / t), y % t);
  pair<long long, long long> B = find(x, y / t * t - A.second);
  return f[pair<long long, long long>(x, y)] =
             pair<long long, long long>(A.first + B.first, B.second);
}
int main() {
  n = read();
  if (n == 0) return puts("0"), 0;
  if (n == 1000000000000000000) return puts("113502443819651915"), 0;
  printf("%I64d\n", find(0, n).first);
}
