#include <bits/stdc++.h>
using namespace std;
int a[1000000 + 10], w;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
pair<int, int> p;
int main() {
  int n, i, temp, then;
  scanf("%d", &n);
  if (!n) {
    printf("0\n");
    return 0;
  }
  for (i = 0; i < n; ++i) a[i] = n;
  a[i] = 0;
  pq.push(make_pair(0, n));
  while (!pq.empty()) {
    p = pq.top();
    pq.pop();
    temp = p.second;
    while (temp) {
      w = temp % 10;
      if (w) {
        then = p.second - w;
        if (!then) {
          goto L;
        }
        if (a[then] == n) {
          a[then] = p.first + 1;
          pq.push(make_pair(a[then], then));
        }
      }
      temp /= 10;
    }
  }
L:
  printf("%d\n", p.first + 1);
  return 0;
}
