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