#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
vector<int> g[N];
int q[N + N], qs, qt, d[N], n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    int cur = i, now;
    while (cur > 0) {
      now = cur % 10;
      if (now > 0 && i >= now) g[i].emplace_back(i - now);
      cur /= 10;
    }
  }
  for (int i = 0; i < n; i++) d[i] = -1;
  qs = qt = d[n] = 0;
  q[qt++] = n;
  int v;
  while (qs < qt && d[0] == -1) {
    v = q[qs++];
    for (int to : g[v])
      if (d[to] == -1) {
        d[to] = d[v] + 1;
        q[qt++] = to;
      }
  }
  printf("%d", d[0]);
  return 0;
}
