#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > f;
pair<long long, int> dp(long long first, int second) {
  if (!first) return pair<long long, int>(0, 0);
  if (first < 10)
    return pair<long long, int>(1LL, (int)max(second - first, 0ll));
  pair<long long, int> now = pair<long long, int>(first, second);
  if (f.count(now)) return f[now];
  long long tmp = 1;
  pair<long long, int> res(0, 0);
  for (; tmp <= first / 10; tmp *= 10)
    ;
  bool z = ((10 - first % 10) + (unsigned long long)first == tmp * 10ull);
  while (first > 0) {
    int bit = max((long long)second, first / tmp);
    pair<long long, int> g = dp(first % tmp, bit);
    res.first += g.first;
    first -= first % tmp + g.second;
    if (!g.second && first) first -= bit, res.first++;
  }
  res.second = -first;
  if (z) f[now] = res;
  return res;
}
int main() {
  long long n;
  scanf("%I64d", &n);
  printf("%I64d\n", dp(n, 0).first);
}
