#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, pair<long long, long long> > dp;
int digs(long long n) {
  int cnt = 0;
  while (n) {
    n /= 10;
    cnt++;
  }
  return cnt;
}
pair<long long, long long> solve(long long n, int mx) {
  if (n == 0) return {0, 0};
  if (n < 10) {
    if (n < mx)
      return {1, mx - n};
    else
      return {1, 0};
  }
  if (dp.count({n, mx})) return dp[{n, mx}];
  long long mod = 1;
  long long newn = n;
  while (digs(mod) < digs(n)) mod *= 10;
  pair<long long, long long> ans = {0, 0};
  while (1) {
    int digit = newn / mod;
    int newmx = mx;
    if (digit > newmx) newmx = digit;
    pair<long long, long long> ans2 = solve(newn % mod, newmx);
    ans.first += ans2.first;
    newn -= newn % mod;
    if (ans2.second > 0)
      newn -= ans2.second;
    else {
      if (newmx > 0) {
        newn -= newmx;
        ans.first++;
      }
    }
    if (digit == 0) break;
  }
  if (newn < 0)
    ans.second = -newn;
  else
    ans.second = 0;
  dp[{n, mx}] = ans;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  int mx = 0;
  cout << solve(n, mx).first;
  return 0;
}
