#include <bits/stdc++.h>
using namespace std;
int pre[1000000 + 2][10];
int carry[1000000 + 2][10];
int get(int n) {
  int r = 0;
  while (n) {
    r = ((r) > (n % 10) ? (r) : (n % 10));
    n /= 10;
  }
  return r;
}
int main() {
  int i, j, k;
  long long n, m;
  i = 0;
  int mi, _mi, _i, _j;
  for (i = 0; i <= 1000000; i++) {
    mi = get(i);
    for (j = 0; j < 10; j++) {
      if (!i) {
        pre[i][j] = 0;
        carry[i][j] = 0;
        continue;
      }
      k = i - ((mi) > (j) ? (mi) : (j));
      _i = ((k) > (0) ? (k) : (0));
      pre[i][j] = pre[_i][j] + 1;
      if (k >= 0)
        carry[i][j] = carry[_i][j];
      else
        carry[i][j] = k;
    }
  }
  cin >> n;
  long long ans = 0, _n;
  while (n) {
    _n = n % 1000000;
    m = get(n / 1000000);
    if (!_n) {
      n -= m;
      ans++;
      continue;
    }
    ans += pre[_n][m];
    n /= 1000000;
    n *= 1000000;
    n += carry[_n][m];
  }
  cout << ans << endl;
  return 0;
}
