#include <bits/stdc++.h>
using namespace std;
int A[20];
int main() {
  int N;
  while (scanf("%d", &N) != EOF) {
    int ans = 0;
    while (N) {
      int t = N;
      int Max = 0;
      while (t) {
        Max = max(Max, t % 10);
        t /= 10;
      }
      N -= Max;
      ans++;
    }
    printf("%d\n", ans);
  }
  return 0;
}
