#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > mp;
long long max(long long a, long long b) { return a >= b ? a : b; }
pair<long long, int> dp(pair<long long, int> x) {
  long long n = x.first, tp = 1;
  int a = x.second;
  if (!n) return pair<long long, int>(0, 0);
  if (n < 10) return pair<long long, int>(1, max(a - n, 0));
  if (mp.find(x) != mp.end()) return mp[x];
  for (; tp < 1e18 && tp * 10 <= n; tp *= 10)
    ;
  pair<long long, int> ret(0, 0);
  for (; n > 0;) {
    int b = max(a, n / tp);
    pair<long long, int> dep = dp(pair<long long, int>(n % tp, b));
    ret.first += dep.first;
    n -= n % tp + dep.second;
    if (n && n % tp == 0) n -= b, ret.first++;
  }
  if (n < 0) ret.second = -n;
  mp.insert(make_pair(x, ret));
  return ret;
}
int main() {
  long long n;
  scanf("%I64d", &n);
  printf("%I64d\n", dp(pair<long long, int>(n, 0)).first);
  return 0;
}
