#include <bits/stdc++.h>
using namespace std;
map<pair<int, long long>, pair<long long, int> > mem;
pair<long long, int> rec(int currLen, int maxFromLeft, long long curr) {
  if (mem.find(make_pair(maxFromLeft, curr)) != mem.end())
    return mem[make_pair(maxFromLeft, curr)];
  long long curr2 = curr;
  if (currLen == 1) {
    return make_pair(1, curr - max((int)curr, maxFromLeft));
  }
  long long ans = 0;
  long long currPow = 1;
  for (int i = 0; i < currLen - 1; i++) currPow *= 10LL;
  while (curr > 0) {
    long long temp = curr;
    for (int i = 0; i < currLen - 1; i++) temp /= 10;
    int currDigit = temp;
    if (curr % currPow == 0) {
      int currMax = max(currDigit, maxFromLeft);
      ans++;
      curr -= currMax;
      continue;
    }
    pair<long long, long long> recAns =
        rec(currLen - 1, max(maxFromLeft, currDigit), curr % currPow);
    ans += recAns.first;
    curr = currPow * currDigit + recAns.second;
  }
  return mem[make_pair(maxFromLeft, curr2)] = make_pair(ans, curr);
}
int dp[1000005][10];
int dp3[1000005][10];
int dp2[1000005];
int main(int argc, char **argv) {
  long long n;
  cin >> n;
  int len = 0;
  long long nn = n;
  while (nn) {
    len++;
    nn /= 10;
  }
  pair<long long, long long> ans = rec(len, 0, n);
  cout << ans.first;
  return 0;
}
