#include <bits/stdc++.h>
using namespace std;
void io_in_data() {
  freopen("data.in", "r", stdin);
  freopen("data1.out", "w", stdout);
}
const int MAXN = 100007;
map<pair<long long, long long>, pair<long long, long long> > mp;
pair<long long, long long> dfs(pair<long long, long long> p) {
  if (p.first == 0) return make_pair(0LL, 0LL);
  if (p.first < 10) return make_pair(1LL, p.first - p.second);
  if (mp.count(p)) return mp[p];
  long long s = 1;
  while (s <= p.first / 10) s *= 10;
  pair<long long, long long> ret = make_pair(0LL, 0LL);
  pair<long long, long long> pt = p;
  while (true) {
    long long h = p.first / s;
    long long mx = max(h, p.second);
    pair<long long, long long> nxt = dfs(make_pair(p.first % s, mx));
    p.first -= p.first % s;
    ret.first += nxt.first;
    if (nxt.second < 0)
      p.first += nxt.second;
    else {
      if (mx > 0) {
        ret.first++;
        p.first -= mx;
      }
    }
    if (!h) break;
  }
  ret.second = p.first;
  return mp[pt] = ret;
}
int main() {
  long long n;
  while (cin >> n) cout << dfs(make_pair(n, 0LL)).first << endl;
  return 0;
}
