#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, pair<long long, long long> > dp;
long long N;
pair<long long, long long> DP(long long n, long long mx) {
  if (n < 10) return pair<long long, long long>(1LL, n - max(mx, n));
  pair<long long, long long> ret = pair<long long, long long>(n, mx);
  if (dp.find(ret) != dp.end()) return dp[ret];
  pair<long long, long long> ans = pair<long long, long long>(0, 0);
  long long bigbit = 1LL;
  while (bigbit < n) bigbit *= 10LL;
  if (bigbit > n) bigbit /= 10LL;
  while (n > 0) {
    pair<long long, long long> tmp = DP(n % bigbit, max(mx, n / bigbit));
    ans.first += tmp.first;
    n = n - n % bigbit + tmp.second;
  }
  ans.second = n;
  dp.insert(
      pair<pair<long long, long long>, pair<long long, long long> >(ret, ans));
  return ans;
}
int main() {
  dp.clear();
  while (cin >> N) {
    if (N > 0)
      cout << DP(N, 0).first << endl;
    else
      cout << "0" << endl;
  }
  return 0;
}
