#include <bits/stdc++.h>
using namespace std;
int dp[10][1010101];
int to[10][1010101];
int main() {
  for (int j = 1; j <= 9; j++) {
    for (int i = 1; i <= 999999; i++) {
      int k = i, dec = j;
      while (k) {
        dec = max(dec, k % 10);
        k /= 10;
      }
      dp[j][i] = 10101010;
      if (i - dec < 0) {
        dp[j][i] = 0;
        to[j][i] = i;
      } else {
        dp[j][i] = dp[j][i - dec] + 1;
        to[j][i] = to[j][i - dec];
      }
    }
  }
  long long N;
  cin >> N;
  int u = N / 1000000, l = N % 1000000;
  long long cnt = 0;
  while (u) {
    int k = u, dec = 0;
    while (k) {
      dec = max(dec, k % 10);
      k /= 10;
    }
    cnt += dp[dec][l];
    l = to[dec][l];
    cnt++;
    l = l - max(dec, l) + 1000000;
    --u;
  }
  cout << (cnt + dp[1][l]) << endl;
  return 0;
}
