#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long count = 0;
  while (n != 0) {
    long long temp = n;
    long long temp1 = n;
    long long maximum = 0;
    while (temp != 0) {
      maximum = max(temp % 10, maximum);
      temp = temp / 10;
    }
    temp1 = temp1 - maximum;
    n = temp1;
    count++;
  }
  cout << count << endl;
}
