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