#include <bits/stdc++.h>
using namespace std;
int get(int x) {
  int re = 0;
  while (x) {
    re = max(re, x % 10);
    x /= 10;
  }
  return re;
}
int main(void) {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int re = 0;
  while (n) {
    n -= get(n);
    re++;
  }
  cout << re << endl;
  return 0;
}
