#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int main() {
  a[0] = 0;
  int i, j, n;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    j = i;
    a[i] = 10000005;
    while (j) {
      a[i] = min(a[i], a[i - j % 10] + 1);
      j /= 10;
    }
  }
  printf("%d\n", a[n]);
}
