#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  int n, res = 0, t, b;
  cin >> n;
  while (n) {
    res++;
    t = n;
    b = -1;
    while (t) {
      b = max(b, t % 10);
      t /= 10;
    }
    n -= b;
  }
  cout << res << endl;
  return 0;
}
