#include <bits/stdc++.h>
using namespace std;
long long ans(long long n) {
  long long m = 0;
  while (n) {
    m = ((n % 10 > m) ? n % 10 : m);
    n = n / 10;
  }
  return m;
}
int main() {
  long long n;
  cin >> n;
  long long c = 0;
  while (n) {
    n = n - (ans(n));
    c++;
  }
  cout << c << endl;
  return 0;
}
