#include <bits/stdc++.h>
using namespace std;
const int N = 800, mod = 1e9 + 7;
long long n;
map<pair<long long, long long>, pair<long long, long long> > mp;
pair<long long, long long> solve(long long n, int m) {
  if (n < 10) return pair<long long, long long>(1, n > m ? 0 : n - m);
  if (mp.find(pair<long long, long long>(n, m)) != mp.end())
    return mp[pair<long long, long long>(n, m)];
  long long p = 1;
  while (p <= n / 10) p *= 10;
  pair<long long, long long> t = solve(n - n / p * p, max(m, (int)(n / p)));
  long long tn = n / p * p + t.second;
  pair<long long, long long> res = solve(tn, m);
  res.first += t.first;
  return mp[pair<long long, long long>(n, m)] = res;
}
int main() {
  cin >> n;
  if (n == 0)
    cout << 0;
  else
    cout << solve(n, 0).first;
}
