#include <bits/stdc++.h>
using namespace std;
long long n;
set<pair<long long, long long> > solved;
map<pair<long long, long long>, pair<long long, long long> > dp;
pair<long long, long long> solve(long long num, long long pre) {
  if (num <= 0) return make_pair(0, -num);
  if (num < 10) return make_pair(1, max(0ll, -(num - pre)));
  pair<long long, long long> kval = make_pair(num, pre);
  if (solved.find(kval) != solved.end()) return dp[kval];
  long long a = 1;
  while (a <= num / 10) {
    a *= 10;
  }
  long long tans = 0;
  while (num > 0) {
    long long rem = num % a;
    long long fdg = num / a;
    pair<long long, long long> mov = solve(rem, max(fdg, pre));
    tans += mov.first;
    num = num - rem - mov.second;
    if (mov.second == 0 && fdg > 0) {
      ++tans;
      num -= max(pre, fdg);
    }
  }
  solved.insert(kval);
  dp[kval] = make_pair(tans, -num);
  return dp[kval];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  cout << solve(n, 0).first << endl;
  cin.get();
  cin.get();
  return 0;
}
