#include <bits/stdc++.h>
using namespace std;
int N;
int color[1000900];
int BFS() {
  queue<int> Q;
  memset(color, -1, sizeof(color));
  Q.push(N);
  color[N] = 0;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (u == 0) return color[u];
    int v = u;
    while (v) {
      int x = v % 10;
      if (color[u - x] == -1) {
        color[u - x] = color[u] + 1;
        Q.push(u - x);
      }
      v /= 10;
    }
  }
  return -1;
}
int main() {
  while (cin >> N) {
    int ret = BFS();
    cout << ret << endl;
  }
  return 0;
}
