#include <bits/stdc++.h>
using namespace std;
int a[1000000 + 10], w;
class T {
 public:
  int x, y;
  T(int a, int b) : x(a), y(b) {}
};
bool operator<(const T &t1, const T &t2) { return t1.x > t2.x; }
class T p(0, 0);
priority_queue<T> pq;
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[n] = 0;
  pq.push(T(0, n));
  while (!pq.empty()) {
    p = pq.top();
    pq.pop();
    temp = p.y;
    while (temp) {
      w = temp % 10;
      if (w) {
        then = p.y - w;
        if (!then) {
          goto L;
        }
        if (a[then] == n) {
          a[then] = p.x + 1;
          pq.push(T(a[then], then));
        }
      }
      temp /= 10;
    }
  }
L:
  printf("%d\n", p.x + 1);
  return 0;
}
