#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000100;
const int MAXX = 1000000;
pair<int, int> D[MAXN][10];
inline int maxd(int n) {
  long long k = n;
  int d = 0;
  while (k > 0) {
    d = max(d, int(k % 10));
    k /= 10;
  }
  return d;
}
pair<int, int> get(int n, int m) {
  if (n <= 0) return pair<int, int>(0, n);
  if (D[n][m].first != -1) return D[n][m];
  int d = max(m, maxd(n));
  pair<int, int> r = get(n - d, m);
  return D[n][m] = pair<int, int>(1 + r.first, r.second);
}
long long sub(long long n) {
  long long s = 0;
  while (true) {
    long long l = (n / MAXX);
    int r = n % MAXX;
    if (l == 0) return s + get(n, 0).first;
    int mm = maxd(l);
    pair<int, int> r1 = get(r, mm);
    l *= MAXX;
    if (r1.second == 0) {
      s += r1.first + 1;
      n = l - mm;
      continue;
    }
    s += r1.first;
    n = l + r1.second;
  }
}
int main() {
  long long n;
  scanf("%I64d", &n);
  for (int j = 0; j < 10; j++) D[0][j] = pair<int, int>(0, 0);
  for (int i = 1; i <= min((long long)MAXN - 1, n); i++)
    for (int j = 0; j < 10; j++) {
      int d = max(maxd(i), j);
      if (i - d < 0)
        D[i][j] = pair<int, int>(1, i - d);
      else
        D[i][j] = pair<int, int>(1 + D[i - d][j].first, D[i - d][j].second);
    }
  printf("%I64d\n", sub(n));
  return 0;
}
