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