#include <bits/stdc++.h>
using namespace std;
const int Maxn = 19;
long long n, p[Maxn];
map<pair<long long, int>, pair<long long, int> > f;
pair<long long, int> calc(int idx, pair<long long, int> x) {
  if (idx == 1)
    return x.first >= x.second ? pair<long long, int>(1, 0)
                               : pair<long long, int>(0, x.first);
  if (f.find(x) != f.end()) return f[x];
  int t = x.first / p[idx - 1];
  long long num = x.first - t * p[idx - 1];
  pair<long long, int> ans(0, 0);
  for (int i = t; i > 0; i--) {
    pair<long long, int> res =
        calc(idx - 1, pair<long long, int>(num, max(i, x.second)));
    ans.first += res.first + 1;
    num = p[idx - 1] + res.second - max(i, x.second);
  }
  pair<long long, int> res = calc(idx - 1, pair<long long, int>(num, x.second));
  ans.first += res.first;
  ans.second += res.second;
  return f[x] = ans;
}
int main() {
  cin >> n;
  p[0] = 1;
  for (int i = 1; i <= 18; i++) p[i] = p[i - 1] * 10;
  int len = 0;
  for (long long x = n; x; x /= 10) ++len;
  cout << (n == 0 ? 0 : calc(len, pair<long long, int>(n, 0)).first) << endl;
  return 0;
}
