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