#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long ncopy;
  int count = 0;
  while (n) {
    long long large = INT_MIN;
    ncopy = n;
    while (ncopy) {
      large = max(large, ncopy % 10);
      ncopy /= 10;
    }
    n -= large;
    count++;
  }
  cout << count << endl;
  return;
}
int main() {
  solve();
  return 0;
}
