#include <bits/stdc++.h>
using namespace std;
map<char, int> to_int;
long long int memo[19][10][10][2];
long long int power(long long int base, int exponent) {
  long long int ret = 1;
  while (exponent--) {
    ret *= base;
  }
  return ret;
}
pair<long long int, int> finder3(string s, char ghigh) {
  pair<long long int, int> ret;
  char high, last, thigh;
  long long int a = stoll(s), counter = 0, new9, to_add;
  bool is9;
  int not9, digits;
  string nine;
  while (a > 9) {
    nine = "";
    not9 = 0;
    is9 = 0;
    digits = 0;
    s = to_string(a);
    high = ghigh;
    thigh = ghigh;
    for (char& c : s) {
      if (is9) {
        digits++;
        if (c != '9' || not9) not9++;
        nine += c;
        last = c;
      } else if (c == '9') {
        digits++;
        is9 = 1;
        nine += '0';
        high = '9';
      } else {
        c > high ? high = c : ' ';
        c > thigh ? thigh = c : ' ';
      }
    }
    if (nine.size() > 2 && not9 <= 1) {
      to_add = 9 * power(10, digits - 1);
      new9 = stoll(nine) + to_add;
      if (memo[digits][to_int[thigh]][to_int[last]][0] == 0) {
        new9 -= 9;
        counter++;
        ret = finder3(to_string(new9), thigh);
        memo[digits][to_int[thigh]][to_int[last]][0] = ret.first + 1;
        memo[digits][to_int[thigh]][to_int[last]][1] = ret.second;
        counter += ret.first;
        a -= new9 + 9 - ret.second;
      } else {
        a -= new9 - memo[digits][to_int[thigh]][to_int[last]][1];
        counter += memo[digits][to_int[thigh]][to_int[last]][0];
      }
      continue;
    }
    new9 = (is9 ? stoll(nine) / 9 : 0);
    if (new9) {
      a -= 9 * (new9);
      counter += (new9);
    } else {
      a -= to_int[high];
      counter++;
    }
  }
  ret.first = counter;
  ret.second = a;
  return ret;
}
int main() {
  int co = 0;
  long long int counter;
  for (auto c : "0123456789") {
    to_int[c] = co;
    co++;
  }
  string s, ss;
  cin >> s;
  if (s == "0") {
    cout << "0\n";
    return 0;
  }
  counter = finder3(s, '0').first;
  cout << counter + 1 << '\n';
  return 0;
  return 0;
}
