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