#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long ln, lk, lm;
map<pair<long long, long long>, pair<long long, long long>> mp;
long long gg(long long x) {
  long long ans = 1;
  while (x >= 10) {
    x /= 10;
    ans *= 10;
  }
  return ans;
}
pair<long long, long long> dfs(long long x, long long mx) {
  if (x == 0) return {0, 0};
  if (x < 10) {
    if (x >= mx)
      return {1, 0};
    else
      return {1, mx - x};
  }
  pair<long long, long long> sta = {x, mx};
  if (mp.find(sta) != mp.end()) return mp[sta];
  long long y = gg(x);
  long long ans = 0;
  while (1) {
    long long cmax = x / y;
    bool et = (cmax == 0);
    cmax = max(cmax, mx);
    auto p = dfs(x % y, cmax);
    ans += p.first;
    x -= x % y;
    if (p.second > 0) {
      x -= p.second;
    } else {
      x -= cmax;
      if (cmax) ans++;
    }
    if (et) break;
  }
  return mp[sta] = {ans, -x};
}
int main() {
  scanf("%lld", &ln);
  printf("%lld\n", dfs(ln, 0).first);
  return 0;
}
