#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;
const int M = 1e6;
int mxd[M + 1], d[10][M], p[10][M];
long long n;
pair<long long, int> cache[10][10];
pair<long long, int> count(long long x, int dm = 0) {
  int l = x / M, r = x % M;
  long long sm = 0, last;
  while (l >= 0) {
    sm += d[max(dm, mxd[l])][r];
    last = p[max(dm, mxd[l])][r];
    l--;
    r = M - last;
  }
  return {sm, last};
}
int main() {
  cin >> n;
  for (int i = 0; i <= M; i++) {
    mxd[i] = max(mxd[i / 10], i % 10);
  }
  for (int i = 1; i < 10; i++) {
    p[i][0] = i;
    d[i][0] = 1;
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 1; j < M; j++) {
      if (j < i) {
        p[i][j] = i - j;
        d[i][j] = 1;
      } else {
        int k = max(mxd[j], i);
        d[i][j] = d[i][j - k] + 1;
        p[i][j] = p[i][j - k];
      }
    }
  }
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) cache[i][j] = count((long long)M * M - j, i);
  long long l = n / ((long long)M * M), r = n % ((long long)M * M);
  long long sm = 0, last;
  pair<long long, int> a;
  a = count(r, mxd[l]);
  sm += a.first, last = a.second;
  l--;
  while (l >= 0) {
    sm += cache[mxd[l]][last].first;
    last = cache[mxd[l]][last].second;
    l--;
  }
  cout << sm;
}
