#include <bits/stdc++.h>
int main() {
  int a[100000], b, c, i, j, n, k = 0, m, max, sum = 0, flag = 1;
  char arr[100000];
  scanf("%d", &n);
  while (n != 0) {
    max = 0;
    m = n;
    while (m != 0) {
      b = m % 10;
      m = m / 10;
      if (max < b) max = b;
    }
    n = n - max;
    ++k;
  }
  printf("%d\n", k);
  return 0;
}
