#include <bits/stdc++.h>
int min(int num);
std::unordered_map<int, int> min_table;
int min(int num) {
  if (num == 0) return 0;
  if (min_table.find(num) == min_table.end()) {
    int m = INT_MAX;
    for (char c : std::to_string(num)) {
      if (c == '0') continue;
      int v = num - (c - '0');
      m = std::min(m, min(v) + 1);
    }
    min_table[num] = m;
  }
  return min_table[num];
}
int main() {
  int n;
  std::cin >> n;
  std::cout << min(n);
}
