#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, pair<long long, long long> > m;
long long n;
pair<long long, long long> greedy(long long num, long long mayor) {
  pair<long long, long long> current = make_pair(0, 0);
  if (num == 0) return current;
  if (num < 10) {
    current.first = 1;
    if (num < mayor) current.second = mayor - num;
    return current;
  }
  current.first = num;
  current.second = mayor;
  if (m.find(current) != m.end()) return m[current];
  long long pot = 1;
  for (int i = 0; i < 19; i++) {
    if (num / pot < 10) break;
    pot *= 10;
  }
  pair<long long, long long> answer = make_pair(0, 0);
  while (true) {
    long long dig = num / pot;
    long long mx = max(mayor, dig);
    pair<long long, long long> res = greedy(num % pot, mx);
    num -= num % pot;
    answer.first += res.first;
    if (res.second == 0 && mx > 0) {
      answer.first++;
      num -= mx;
    } else
      num -= res.second;
    if (dig == 0) break;
  }
  answer.second = -num;
  m[current] = answer;
  return answer;
}
int main() {
  cin >> n;
  cout << greedy(n, 0).first << endl;
  return 0;
}
