#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > dp;
long long n;
pair<long long, int> solve(long long n, int mx) {
  if (n == 0)
    return make_pair(0, 0);
  else if (n < 10)
    return make_pair(1, max(mx - n, 0ll));
  pair<long long, int> s = make_pair(n, mx), res = make_pair(0, 0);
  if (dp.count(s)) return dp[s];
  long long pw = 1;
  while (n / 10 >= pw) pw *= 10;
  while (1) {
    int d = n / pw, nx = max(mx, d);
    pair<long long, int> re = solve(n % pw, nx);
    n -= n % pw;
    res.first += re.first;
    if (re.second)
      n -= re.second;
    else
      n -= nx, res.first += !!nx;
    if (!d) break;
  }
  res.second = -n;
  return dp[s] = res;
}
int main() {
  scanf("%I64d", &n);
  printf("%I64d\n", solve(n, 0).first);
}
