#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > mp;
pair<long long, int> go(long long v, int mx) {
  if (v == 0) return make_pair(0, 0);
  if (v < 10) {
    pair<long long, int> ans = make_pair(1, 0);
    if (v < mx) ans.second = (mx - v);
    return ans;
  }
  pair<long long, int> state = make_pair(v, mx);
  if (mp.find(state) != mp.end()) return mp[state];
  long long step = 1;
  while (step <= v / 10) step *= 10;
  pair<long long, int> ans = make_pair(0, 0);
  while (true) {
    int dig = v / step;
    int newmx = mx;
    if (dig > newmx) newmx = dig;
    pair<long long, int> cur = go(v % step, newmx);
    ans.first += cur.first;
    v -= v % step;
    if (cur.second > 0)
      v -= cur.second;
    else {
      v -= newmx;
      if (newmx > 0) ans.first++;
    }
    if (dig == 0) break;
  }
  ans.second = -v;
  mp[state] = ans;
  return ans;
}
int main() {
  long long n;
  cin >> n;
  pair<long long, int> result = go(n, 0);
  cout << result.first << endl;
  return 0;
}
