#include <bits/stdc++.h>
using namespace std;
typedef struct {
  unsigned long long times;
  unsigned long long decrementValue;
} result_decrement_1_struct;
result_decrement_1_struct getMinimunTimes(unsigned long long n,
                                          unsigned char maxDigit) {
  static map<pair<unsigned long long, unsigned char>, result_decrement_1_struct>
      _cache = map<pair<unsigned long long, unsigned char>,
                   result_decrement_1_struct>();
  unsigned long long times = 0;
  unsigned long long decrementValue = 0;
  pair<unsigned long long, unsigned char> initalInput =
      pair<unsigned long long, unsigned char>(n, maxDigit);
  if (_cache.count(initalInput)) return _cache[initalInput];
  result_decrement_1_struct result;
  while (true) {
    if (!n) {
      result_decrement_1_struct r = {
        times : times,
        decrementValue : decrementValue
      };
      result = r;
      break;
    }
    if (n < maxDigit) {
      result_decrement_1_struct r = {
        times : times,
        decrementValue : decrementValue
      };
      result = r;
      break;
    }
    if (maxDigit == 9) {
      result_decrement_1_struct r = {
        times : times + n / 9,
        decrementValue : decrementValue + (n / 9) * 9
      };
      result = r;
      break;
    }
    if (n < 10) {
      result_decrement_1_struct r = {
        times : times + 1,
        decrementValue :
                decrementValue + max(maxDigit, static_cast<unsigned char>(n))
      };
      result = r;
      break;
    }
    unsigned long long pow = 1;
    while (n >= pow) pow *= 10;
    pow /= 10;
    unsigned long long maxDigitIterator =
        max(maxDigit, static_cast<unsigned char>(n / pow));
    unsigned long long low_n = n % pow;
    result_decrement_1_struct iteResult =
        getMinimunTimes(low_n, maxDigitIterator);
    if (iteResult.decrementValue == 0) {
      times++;
      decrementValue += maxDigitIterator;
      n -= maxDigitIterator;
    } else {
      times += iteResult.times;
      decrementValue += iteResult.decrementValue;
      n -= iteResult.decrementValue;
    }
    {
      pair<unsigned long long, unsigned char> inputIte =
          pair<unsigned long long, unsigned char>(n, maxDigit);
      if (_cache.count(inputIte)) {
        result = _cache[inputIte];
        result.times += times;
        result.decrementValue += decrementValue;
        break;
      }
    }
  }
  _cache[initalInput] = result;
  return result;
}
int main() {
  unsigned long long n;
  cin >> n;
  cout << getMinimunTimes(n, 0).times << endl;
}
