#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, d, x, mx, i, j, step = 0;
  cin >> n;
  while (n > 0) {
    step++;
    x = n;
    mx = -1;
    while (x != 0) {
      mx = max(mx, x % 10);
      x /= 10;
    }
    n -= mx;
  }
  cout << step << '\n';
  return 0;
}
