#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const double eps = 1e-9;
const double INF = inf;
const double EPS = eps;
long long Deg[20];
map<pair<long long, int>, pair<long long, int> > M;
pair<long long, int> solve(long long n, int y) {
  long long nn = n;
  if (M.count(make_pair(n, y)) != 0) return M[make_pair(n, y)];
  int i;
  long long res = 0;
  if (n >= 10) {
    int it = 0;
    while (n >= Deg[it + 1]) it++;
    while (n >= Deg[it]) {
      long long m = n % Deg[it];
      if (m == 0) {
        n -= max((int)(n / Deg[it]), y), res++;
        continue;
      }
      pair<long long, int> ret = solve(m, max(y, (int)(n / Deg[it])));
      res += ret.first;
      n -= m, n += ret.second;
    }
    pair<long long, int> ret = solve(n, y);
    res += ret.first, n = ret.second;
  } else {
    while (n > 0) {
      int md = y, tmp;
      for (i = 0; Deg[i] <= n; i++) {
        tmp = (n / Deg[i]) % 10;
        if (md <= tmp) md = tmp;
      }
      n -= md, res++;
    }
  }
  M[make_pair(nn, y)] = make_pair(res, n);
  return make_pair(res, n);
}
int main() {
  int i;
  long long n, res = 0;
  for (Deg[0] = 1, i = 1; i < 20; i++) Deg[i] = Deg[i - 1] * 10;
  scanf("%I64d", &n);
  if (n == Deg[18]) n--, res++;
  res += solve(n, 0).first;
  printf("%I64d\n", res);
  ;
  return 0;
}
