#include <bits/stdc++.h>
using namespace std;
int ans = 0;
int top = 0;
int main() {
  int n;
  int jiwei[7];
  scanf("%d", &n);
  if (n == 0)
    ans = 0;
  else {
    while (n != 0) {
      top = 0;
      int k = n;
      memset(jiwei, 0, sizeof(jiwei));
      while (k != 0) {
        jiwei[top++] = k % 10;
        k = k / 10;
      }
      sort(jiwei, jiwei + top);
      n -= jiwei[top - 1];
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
