#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, t, r, m;
  cin >> n;
  r = 0;
  while (n) {
    r++;
    m = -1;
    t = n;
    while (t) {
      m = m > t % 10 ? m : t % 10;
      t /= 10;
    }
    n -= m;
  }
  cout << r << endl;
  return 0;
}
