#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  while (n) {
    int m = n;
    int a = m % 10;
    while (m) {
      m /= 10;
      a = max(a, m % 10);
    }
    n -= a;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}
