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