#include <bits/stdc++.h>
using namespace std;
long long tp[20];
struct ans {
  long long step;
  long long rem;
  ans() { step = -1ll; }
  ans(long long s, long long r) : step(s), rem(r) {}
};
ans f[10][20][11];
ans query(int h, int n, long long x) {
  int xx = (x / 10 == tp[n - 1] - 1) ? x % 10 : 10;
  ans &key = f[h][n][xx];
  if (~key.step) return key;
  if (n == 1) {
    if (x >= h)
      return key = ans(1, 0);
    else
      return key = ans(0, x);
  }
  long long cnt = 0, cur = x % tp[n - 1];
  int t = x / tp[n - 1];
  while (t >= 0) {
    ans tmp = query(max(h, t), n - 1, cur);
    cnt += tmp.step;
    cur = tmp.rem;
    if (t) {
      cur = cur + tp[n - 1] - max(h, t);
      cnt++;
    }
    t--;
  }
  return key = ans(cnt, cur);
}
int main() {
  tp[0] = 1ll;
  for (int i = 1; i <= 18; i++) tp[i] = tp[i - 1] * 10ll;
  tp[19] = 9000000000000000000ll;
  long long n;
  int p = 0;
  scanf("%I64d", &n);
  if (n == 0) {
    printf("0");
    return 0;
  }
  while (tp[p] <= n) p++;
  ans tmp = query(0, p, n);
  printf("%I64d", tmp.step);
}
