#include <bits/stdc++.h>
using namespace std;
int largest(int n) {
  int d = 0;
  while (n) {
    if (n % 10 > d) d = n % 10;
    n /= 10;
  }
  return d;
}
void solve() {
  int n;
  cin >> n;
  if (n == 0) {
    cout << 0;
    return;
  }
  if (n < 10) {
    cout << 1;
    return;
  }
  int arr[10] = {0};
  for (int i = 1; i < 10; i++) arr[i] = 1;
  for (int i = 10; i <= n; i++) {
    arr[i % 10] = 1 + arr[(i - largest(i)) % 10];
  }
  cout << arr[n % 10];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
