#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
map<pair<long long, long long>, pair<long long, long long> > mp;
pair<long long, long long> dfs(long long n, long long m) {
  if (n == 0) return make_pair(n || m, -m);
  if (n > 0 && n <= 9) return make_pair(1ll, n - max(n, m));
  if (mp.find(make_pair(n, m)) != mp.end()) return mp[make_pair(n, m)];
  long long p = 1, temp = n;
  while (temp /= 10) p *= 10;
  pair<long long, long long> t1 = dfs(n % p, max(m, n / p));
  pair<long long, long long> t2 = dfs(n / p * p + t1.second, m);
  t2.first += t1.first;
  return mp[make_pair(n, m)] = t2;
}
int main() {
  long long n;
  while (~scanf("%I64d", &n)) {
    mp.clear();
    printf("%I64d\n", dfs(n, 0).first);
  }
  return 0;
}
