#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
struct greateri {
  template <class T>
  bool operator()(T const &a, T const &b) const {
    return a > b;
  }
};
map<pair<long long, long long>, pair<long long, long long> > dp;
pair<long long, long long> solve(long long val, long long mx) {
  if (val == 0) return {0, 0};
  if (val < 10) {
    pair<long long, long long> ans = {1, 0};
    if (mx > val) {
      ans.second = val - mx;
    }
    return ans;
  }
  pair<long long, long long> nei = {val, mx};
  if (dp.find(make_pair(val, mx)) != dp.end()) return dp[{val, mx}];
  long long lim = 1;
  while (lim <= val / 10) lim *= 10;
  pair<long long, long long> ans = {0, 0};
  while (1) {
    int newx = mx;
    int dig = val / lim;
    if (dig > newx) newx = dig;
    pair<long long, long long> tmp = solve(val % lim, newx);
    ans.first += tmp.first;
    val -= val % lim;
    if (tmp.second < 0)
      val += tmp.second;
    else if (tmp.second == 0) {
      val -= newx;
      if (newx > 0) ans.first++;
    }
    if (dig == 0) break;
  }
  ans.second = val;
  return dp[nei] = ans;
}
int main() {
  dp.clear();
  long long xo;
  cin >> xo;
  cout << solve(xo, 0).first;
  return 0;
}
