#include <bits/stdc++.h>
int len;
int big;
int Dgt[30];
int N;
int ans;
void tochar(int);
int main() {
  while (scanf("%d", &N) != EOF) {
    memset(Dgt, 0, sizeof(Dgt));
    ans = 0;
    while (N) {
      big = -1;
      tochar(N);
      for (int i = 0; i < len; i++) {
        if (Dgt[i] > big) big = Dgt[i];
      }
      N -= big;
      ans++;
    }
    printf("%d\n", ans);
  }
}
void tochar(int n) {
  len = 0;
  while (n) {
    Dgt[len] = n % 10;
    n /= 10;
    len++;
  }
}
