#include <bits/stdc++.h>
using namespace std;
const long long N = 20;
long long n;
unsigned long long p[N];
struct ans {
  long long t, d;
  ans(long long T = 0, long long D = 0) : t(T), d(D) {}
};
map<pair<long long, pair<long long, long long> >, ans> m;
ans solve(long long mx, long long n, long long l) {
  if (n == 0) return ans(0, 0);
  if (l == 1) {
    if (mx > n)
      return ans(0, n);
    else
      return ans(1, 0);
  }
  if (m.count(make_pair(mx, make_pair(n, l))))
    return m[make_pair(mx, make_pair(n, l))];
  long long fir = n / p[l - 1];
  long long ret = 0, nn = n;
  while (n) {
    ans tmp = solve(max(fir, mx), n % p[l - 1], l - 1);
    ret += tmp.t;
    n = fir * p[l - 1] + tmp.d;
    if (fir == 0) break;
    n -= max(fir, mx);
    ret++;
    fir--;
  }
  return m[make_pair(mx, make_pair(nn, l))] = (ans){ret, n};
}
signed main() {
  cin >> n;
  p[0] = 1;
  for (long long i = (1); i < (N - 1); ++i) p[i] = p[i - 1] * 10;
  p[N - 1] = 9e18;
  long long len = 0;
  while ((unsigned long long)n >= p[len]) ++len;
  cout << solve(0, n, len).t;
}
