#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d, e, f, g, x;
  char i;
  int compteur = 0;
  cin >> n;
  while (n != 0) {
    x = n;
    g = x / 1000000;
    x %= 1000000;
    f = x / 100000;
    x %= 100000;
    e = x / 10000;
    x %= 10000;
    d = x / 1000;
    x %= 1000;
    c = x / 100;
    x %= 100;
    b = x / 10;
    a = x % 10;
    n -= max(max(a, max(b, c)), max(d, max(e, max(f, g))));
    compteur++;
  }
  cout << compteur << endl;
  return 0;
}
