#include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 28;
const long long mod = 1LL;
int main() {
  long long n, i, j, k;
  while (cin >> n) {
    k = 0;
    while (n != 0) {
      i = n;
      j = 0;
      while (i != 0) {
        if (i % 10 > j) j = i % 10;
        i /= 10;
      }
      k++;
      n = n - j;
    }
    cout << k << "\n";
  }
  return 0;
}
