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