#include <bits/stdc++.h>
using namespace std;
int get_largest(unsigned long long int num) {
  int largest = 0;
  while (num > 0) {
    if (num % 10 > largest) {
      largest = num % 10;
    }
    num /= 10;
  }
  return largest;
}
const int max_n = 1e6;
pair<int, int> memo[max_n][10];
void pre_solve() {
  for (int i = 0; i < max_n; i++) {
    for (int j = 0; j < 10; j++) {
      int n = i - max(j, get_largest(i));
      int curr = 1;
      if (n > 0) {
        curr += memo[n][j].first;
        n = memo[n][j].second;
      }
      memo[i][j] = {curr, n};
    }
  }
}
int main() {
  pre_solve();
  unsigned long long int n;
  cin >> n;
  unsigned long long int curr_count = 0;
  while (n > 0) {
    unsigned long long int working = n % max_n;
    int largest_past_working = get_largest(n / max_n);
    if (working == 0) {
      n -= largest_past_working;
      curr_count++;
      continue;
    }
    curr_count += memo[working][largest_past_working].first;
    n -= working;
    n += memo[working][largest_past_working].second;
  }
  cout << curr_count << endl;
}
