#include <bits/stdc++.h>
using namespace std;
long long d[19];
map<long long, pair<long long, int> > S;
pair<long long, int> Dfs(long long n, int x, int z) {
  long long t = (n * 18 + x) * 10 + z;
  if (!x)
    return n ? pair<long long, int>(1, n > z ? 0 : n - z)
             : pair<long long, int>(0, 0);
  if (S.count(t)) return S[t];
  long long ans = 0;
  while (n > 0) {
    int w = n / d[x];
    pair<long long, int> t1 = Dfs(n % d[x], x - 1, max(w, z));
    ans += t1.first;
    if (w && !t1.second)
      n = w * d[x] - max(z, w), ans++;
    else
      n = w * d[x] + t1.second;
  }
  return S[t] = pair<long long, int>(ans, n);
}
int main() {
  long long n;
  scanf("%I64d", &n);
  d[0] = 1;
  for (int i = 1; i < 19; i++) d[i] = d[i - 1] * 10;
  printf("%I64d\n", Dfs(n, 18, 0).first);
}
