#include <bits/stdc++.h>
using namespace std;
int m, n, maxn, cnt;
int main() {
  cin >> n;
  while (n > 0) {
    m = n;
    maxn = 0;
    while (m > 0) {
      maxn = max(maxn, m % 10);
      m = m / 10;
    }
    n -= maxn;
    cnt++;
  }
  cout << cnt;
}
