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