#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > dp;
long long n;
pair<long long, int> calc(long long now, int limit) {
  if (now == 0) return make_pair(0, 0);
  pair<long long, int> ans = make_pair(0, 0);
  if (now < 10) {
    ans = make_pair(1, 0);
    if (limit > now) ans = make_pair(1, now - limit);
    return ans;
  }
  pair<long long, int> tmp = make_pair(now, limit);
  if (dp.find(tmp) != dp.end()) return dp[tmp];
  long long w = 1;
  while (w <= now / 10) w *= 10;
  while (1) {
    int digit = now / w, nexlimit = limit;
    if (digit > limit) nexlimit = digit;
    pair<long long, int> ntmp = calc(now % w, nexlimit);
    ans.first += ntmp.first;
    now -= now % w;
    if (ntmp.second)
      now += ntmp.second;
    else {
      now -= nexlimit;
      if (nexlimit > 0) ans.first++;
    }
    if (digit == 0) break;
  }
  ans.second = now;
  dp[tmp] = ans;
  return ans;
}
int main() {
  cin >> n;
  cout << calc(n, 0).first << endl;
}
