#include <bits/stdc++.h>
using namespace std;
int n, f[1000001];
int main() {
  cin >> n;
  f[n] = 0;
  while (n != 0) {
    int o = n, b = 0;
    while (o != 0) {
      b = max(o % 10, b);
      o = o / 10;
    }
    f[n - b] = f[n] + 1;
    n -= b;
  }
  cout << f[0];
}
