#include <bits/stdc++.h>
using namespace std;
bool done[10][20][10];
long long memval[10][20][10];
int memnlast[10][20][10];
long long calc2(int maxprefdig, int ninelen, int last, int &nlast) {
  if (done[maxprefdig][ninelen][last]) {
    nlast = memnlast[maxprefdig][ninelen][last];
    return memval[maxprefdig][ninelen][last];
  }
  nlast = last;
  long long ret = 0;
  if (ninelen == 0) {
    while (nlast >= 0) {
      ++ret;
      nlast -= max(nlast, maxprefdig);
    }
    nlast += 10;
  } else {
    for (int i = (0); i < (10); ++i) {
      int nnlast;
      long long cur = calc2(max(9 - i, maxprefdig), ninelen - 1, nlast, nnlast);
      ret += cur;
      nlast = nnlast;
    }
  }
  done[maxprefdig][ninelen][last] = true;
  memval[maxprefdig][ninelen][last] = ret;
  memnlast[maxprefdig][ninelen][last] = nlast;
  return ret;
}
long long calc(long long prefix, int ninelen, int last, int &nlast) {
  int maxprefdig = -1;
  for (long long x = prefix; x != 0; x /= 10) {
    int cur = x % 10;
    if (cur > maxprefdig) maxprefdig = cur;
  }
  long long ret = calc2(maxprefdig, ninelen, last, nlast);
  return ret;
}
long long n;
long long bf(long long n) {
  long long ret = 0;
  while (n != 0) {
    int cur = -1;
    for (long long x = n; x != 0; x /= 10) cur = max(cur, (int)(x % 10));
    ++ret;
    n -= cur;
  }
  return ret;
}
void run(int casenr) {
  cin >> n;
  long long ret = 0;
  long long prefix = n / 10;
  int ninelen = 0;
  int last = n % 10;
  while (prefix != 0) {
    if (prefix % 10 == 9) {
      prefix /= 10;
      ++ninelen;
      continue;
    }
    int nlast;
    long long cur = calc(prefix, ninelen, last, nlast);
    ret += cur;
    --prefix;
    last = nlast;
  }
  while (ninelen != 0) {
    for (int i = (0); i < (9); ++i) {
      int nlast;
      long long cur = calc(9 - i, ninelen - 1, last, nlast);
      ret += cur;
      last = nlast;
    }
    --ninelen;
  }
  if (last != 0) {
    ++ret;
    last = 0;
  }
  cout << ret << endl;
}
int main() {
  run(1);
  return 0;
}
