#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, l, k = 0, maxi;
  scanf("%d", &n);
  long long int count = 0;
  int a[15];
  l = n;
  while (l) {
    a[k] = l % 10;
    l = l / 10;
    k++;
  }
  while (k > 0) {
    maxi = 0;
    for (i = 0; i < k; i++)
      if (a[i] > maxi) maxi = a[i];
    n = n - maxi;
    k = 0;
    l = n;
    while (l) {
      a[k] = l % 10;
      l = l / 10;
      k++;
    }
    count++;
  }
  if (n == 0)
    cout << count << endl;
  else
    cout << count + 1 << endl;
  return 0;
}
