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