#include <bits/stdc++.h>
using namespace std;
long long pw10[19];
struct Result {
  long long cnt;
  int rem;
  inline Result(long long _cnt = 0, int _rem = 0) : cnt(_cnt), rem(_rem) {}
};
Result mem[22][12][12];
bool vis[22][12][12];
Result dp(int i, int j, int k) {
  if (i == 1) {
    if (k >= j)
      return Result(1, 0);
    else
      return Result(0, k);
  }
  if (vis[i][j][k]) return mem[i][j][k];
  vis[i][j][k] = true;
  long long cnt = 0;
  int t = k;
  for (int c = 9; c >= 0; --c) {
    Result nxt = dp(i - 1, max(j, c), t);
    cnt += nxt.cnt;
    if (c) {
      t = 10 + nxt.rem - max(j, c);
      ++cnt;
    } else
      t = nxt.rem;
  }
  return mem[i][j][k] = Result(cnt, t);
}
inline long long f(long long a) {
  if (!a) return 0;
  long long cnt = 0;
  int ax[20], x = 0, sufmx[20];
  for (long long t = a; t; t /= 10) ax[++x] = int(t % 10);
  sufmx[x + 1] = 0;
  for (int i = x; i >= 1; --i) sufmx[i] = max(sufmx[i + 1], ax[i]);
  int t = ax[1];
  if (ax[1] == sufmx[1]) {
    t = 0;
    ++cnt;
  }
  for (int i = 2; i <= x; ++i)
    if (ax[i]) {
      t = 10 + t - max(sufmx[i + 1], ax[i]);
      ++cnt;
      for (int c = ax[i] - 1; c >= 0; --c) {
        Result nxt = dp(i - 1, max(sufmx[i + 1], c), t);
        cnt += nxt.cnt;
        if (c) {
          t = 10 + nxt.rem - max(sufmx[i + 1], c);
          ++cnt;
        } else
          t = nxt.rem;
      }
    }
  return cnt;
}
int main() {
  pw10[0] = 1;
  for (int i = 1; i <= 18; ++i) pw10[i] = pw10[i - 1] * 10LL;
  long long n;
  scanf("%I64d", &n);
  printf("%I64d\n", f(n));
  return 0;
}
