#include <bits/stdc++.h>
using std::make_pair;
using std::map;
using std::pair;
map<pair<long long, int>, pair<long long, int> > mp;
pair<long long, int> gao(long long val, int mx) {
  if (val == 0) return make_pair(0, 0);
  if (val < 10) {
    pair<long long, int> ans = make_pair(1, 0);
    if (val < mx) ans.second = val - mx;
    return ans;
  }
  pair<long long, int> now = make_pair(val, mx);
  if (mp.find(now) != mp.end()) return mp[now];
  long long lim = 1;
  while (lim <= val / 10) lim *= 10;
  pair<long long, int> ans = make_pair(0, 0);
  while (true) {
    int newmx = mx;
    int dig = val / lim;
    if (dig > newmx) newmx = dig;
    pair<long long, int> tmp = gao(val % lim, newmx);
    ans.first += tmp.first;
    val -= val % lim;
    if (tmp.second < 0)
      val += tmp.second;
    else if (tmp.second == 0) {
      val -= newmx;
      if (newmx > 0) ans.first++;
    }
    if (dig == 0) break;
  }
  ans.second = val;
  mp[now] = ans;
  return ans;
}
int main() {
  mp.clear();
  long long n;
  scanf("%I64d", &n);
  printf("%I64d\n", gao(n, 0).first);
  return 0;
}
