#include <bits/stdc++.h>
using namespace std;
int max_digit(int n) {
  int i = n % 10;
  n /= 10;
  int mx = i;
  while (n) {
    mx = max(mx, n % 10);
    n /= 10;
  }
  return mx;
}
int main() {
  int n;
  cin >> n;
  int soln = (1 ? n > 0 : 0);
  while (n > 9) {
    int mxdig = max_digit(n);
    n -= mxdig;
    soln += 1;
  }
  cout << soln << endl;
  return 0;
}
