#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O3")
int getmax(long long int n) {
  int max = 0;
  while (n) {
    int curr = n % 10;
    n = n / 10;
    if (curr > max) max = curr;
  }
  return max;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int res = 0;
  while (n > 0) {
    int max = getmax(n);
    n -= max;
    res++;
  }
  cout << res << "\n";
  return 0;
}
