#include <bits/stdc++.h>
using namespace std;
int greatest(int x) {
  if (x == 0) return 0;
  return max(x % 10, greatest(x / 10));
}
int n;
int main() {
  cin >> n;
  int cnt = 0;
  while (n) {
    n -= greatest(n);
    cnt++;
  }
  cout << cnt;
}
