#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, pair<long long, long long> > f;
long long n;
pair<long long, long long> dfs(long long mx, long long n) {
  if (f[pair<long long, long long>(mx, n)].first) {
    return f[pair<long long, long long>(mx, n)];
  }
  if (n < 10) {
    return pair<long long, long long>((mx > 0) || (n > 0), max(mx, n) - n);
  }
  long long m = 1;
  while (m <= n / 10) {
    m *= 10;
  }
  long long p = n / m;
  m = p * m;
  pair<long long, long long> a = dfs(max(mx, p), n - m);
  pair<long long, long long> b = dfs(mx, m - a.second);
  return f[pair<long long, long long>(mx, n)] =
             pair<long long, long long>(a.first + b.first, b.second);
}
int main() {
  scanf("%lld", &n);
  printf("%lld\n", dfs(0, n).first);
}
