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