#include <bits/stdc++.h>
using namespace std;
long long n;
long long pw[20];
map<long long, pair<long long, int> > f[20][20];
pair<long long, int> work(int i, int j, long long k) {
  pair<long long, int> ret, s;
  if (f[i][j].find(k) != f[i][j].end()) return f[i][j][k];
  ret.first = 0;
  ret.second = 0;
  if (i == 1) {
    if (j > k || j == 0) {
      ret.first = 1;
      ret.second = k - max(j, (int)k);
    } else {
      ret.first = 2;
      ret.second = (-j);
    }
    return f[i][j][k] = ret;
  }
  if (k / pw[i - 1] == 0)
    return f[i][j][k] = work(i - 1, j, k);
  else {
    s = work(i - 1, max(j, (int)(k / pw[i - 1])), k % pw[i - 1]);
    ret = work(i, j, k / pw[i - 1] * pw[i - 1] + s.second);
    ret.first += s.first;
    return f[i][j][k] = ret;
  }
}
int main() {
  int i, j;
  scanf("%I64d", &n);
  if (n == 0) {
    printf("%I64d\n", 0);
    return 0;
  }
  pw[0] = 1;
  for (i = 1; i <= 18; i++) pw[i] = pw[i - 1] * 10;
  printf("%I64d\n", work(19, 0, n).first);
  return 0;
}
