#include <bits/stdc++.h>
using namespace std;
long long int maxint(long long int n) {
  long long int m = 0;
  while (n) {
    m = max(m, n % 10);
    n = n / 10;
  }
  return m;
}
int main() {
  long long int n;
  cin >> n;
  long long int k = 0;
  while (n) {
    n = n - maxint(n);
    k++;
  }
  cout << k;
  return 0;
}
