#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  while (n) {
    int t = n;
    int maxn = 0;
    while (t) {
      maxn = max(maxn, t % 10);
      t = t / 10;
    }
    n -= maxn;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}
