#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int N = 0, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
int casenum, casei;
long long n;
void solve1e6(long long n) {
  int step = 0;
  while (n) {
    int x = n;
    int mx = 0;
    while (x) gmax(mx, x % 10), x /= 10;
    n -= mx;
    ++step;
  }
  printf("%d\n", step);
}
struct A {
  long long x;
  int y;
  void add(const A &b) {
    x += b.x;
    y = b.y;
  }
};
int a[20];
A f[20][10][10];
A dp(int p, int mx, int tim, int tp) {
  if (p == -1) {
    if (mx == 0) return {0, 0};
    if (tim) return {0, tim - 1};
    return {1, mx - 1};
  }
  if (!tp && ~f[p][mx][tim].x) return f[p][mx][tim];
  A ret = {0, tim};
  int top = tp ? a[p] : 9;
  for (int i = top; i >= 0; --i) {
    ret.add(dp(p - 1, max(mx, i), ret.y, tp && i == top));
  }
  if (!tp) f[p][mx][tim] = ret;
  return ret;
}
void solve1e18(long long n) {
  int p = -1;
  while (n) a[++p] = n % 10, n /= 10;
  if (p == -1) a[++p] = 0;
  for (int i = 0; i <= p; ++i) {
    for (int j = 0; j < 10; ++j) {
      for (int k = 0; k < 10; ++k) f[i][j][k].x = -1;
    }
  }
  printf("%lld\n", dp(p, 0, 0, 1).x);
}
int main() {
  while (~scanf("%lld", &n)) {
    solve1e18(n);
  }
  return 0;
}
