#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  int i = 0;
  long long int b = n;
  int m = 0;
  while (b != 0) {
    do {
      int a = n % 10;
      m = max(a, m);
      n = n / 10;
    } while (n != 0);
    b -= m;
    n = b;
    m = 0;
    i++;
  }
  cout << i;
}
int main() {
  solve();
  return 0;
}
