#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, pair<long long, long long> > mp;
long long n;
pair<long long, long long> dfs(pair<long long, long long> t) {
  if (t.second < 10)
    return pair<long long, long long>(t.first || t.second,
                                      t.second - max(t.second, t.first));
  if (mp.find(t) != mp.end()) return mp[t];
  long long t1, t2;
  pair<long long, long long> res;
  for (t2 = 1; t2 <= t.second / 10; t2 *= 10)
    ;
  res = dfs(
      pair<long long, long long>(max(t.first, t.second / t2), t.second % t2)),
  t1 = res.first;
  res =
      dfs(pair<long long, long long>(t.first, t.second / t2 * t2 + res.second));
  return mp[t] = pair<long long, long long>(t1 + res.first, res.second);
}
int main() {
  scanf("%lld", &n);
  printf("%lld\n", dfs(pair<long long, long long>(0, n)).first);
}
