#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b, m, c;
  cin >> n;
  int* a = new int[n + 1];
  a[0] = 0;
  for (int i = 1; i <= n; ++i) {
    m = INT_MAX;
    b = i;
    while (b) {
      c = b % 10;
      b /= 10;
      if (c) m = min(m, a[i - c]);
    }
    a[i] = m + 1;
  }
  cout << a[n];
}
