#include <bits/stdc++.h>
using namespace std;
int max_digit(int n) {
  int mx = 0;
  while (n) {
    mx = max(mx, n % 10);
    n /= 10;
  }
  return mx;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, n2, count = 0;
  cin >> n;
  n2 = n;
  while (n) {
    n -= max_digit(n);
    ++count;
  }
  cout << count;
  return 0;
}
