#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > T;
long long n;
pair<long long, int> dp(long long n, int m) {
  if (!n) return pair<long long, int>(0, 0);
  if (n < 10) {
    pair<long long, int> t(1, 0);
    if (n < m) t.second = n - m;
    return t;
  }
  if (T.find(pair<long long, int>(n, m)) != T.end())
    return T[pair<long long, int>(n, m)];
  pair<long long, int>& t = T[pair<long long, int>(n, m)];
  t = pair<long long, int>(0, 0);
  long long o = 1;
  while (o <= n / 10) o *= 10;
  while (n > 0) {
    int x = max(1LL * m, n / o);
    pair<long long, int> y = dp(n % o, x);
    t.first += y.first;
    n -= n % o;
    if (y.second < 0)
      n += y.second;
    else {
      n -= x;
      if (x) t.first++;
    }
  }
  t.second = n;
  return t;
}
int main() {
  scanf("%I64d", &n);
  printf("%I64d", dp(n, 0).first);
  return 0;
}
