#include <bits/stdc++.h>
using namespace std;
int step[1000005];
int n;
int BFS() {
  for (int i = (0), _b = (n); i <= _b; i++) step[i] = 1000111222;
  step[n] = 0;
  queue<int> q;
  q.push(n);
  while (!q.empty()) {
    int m = q.front();
    q.pop();
    if (m <= 9) return step[m];
    int tmp = m;
    int p = 10;
    while (tmp) {
      int k = tmp % 10;
      if (step[m - k] == 1000111222) {
        step[m - k] = step[m] + 1;
        q.push(m - k);
      }
      tmp /= 10;
    }
  }
  return 0;
}
int main() {
  while (cin >> n) {
    if (n == 0)
      printf("0");
    else
      cout << BFS() + 1 << endl;
  }
  return 0;
}
