#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long max(long long num) {
  long long max = 1, rem;
  while (num > 0) {
    rem = num % 10;
    num /= 10;
    if (rem > max) {
      max = rem;
    }
  }
  return max;
}
int main() {
  fast();
  int n;
  cin >> n;
  vector<long long> vect(n + 1);
  long long i, count = 0;
  for (i = 1; i <= n; i++) {
    vect[i] = 1;
  }
  for (i = 10; i <= n; i++) {
    vect[i] = vect[i - max(i)] + 1;
  }
  cout << vect[n] << '\n';
  ;
  return 0;
}
