#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000;
int maxVal(long long int num) {
  long long int mx = 0;
  while (num > 0) {
    mx = max(mx, num % 10);
    num /= 10;
  }
  return mx;
}
int val[mod + 10];
int cnt[10][mod + 10];
int decr[10][mod + 10];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n;
  cin >> n;
  val[0] = 0;
  for (int i = 1; i <= mod; i++) {
    val[i] = maxVal(i);
  }
  cnt[0][0] = 0;
  decr[0][0] = 0;
  for (int has = 0; has < 10; has++) {
    for (int i = 0; i <= mod; i++) {
      if (i == 0 && has == 0) continue;
      int next = i - max(has, val[i]);
      if (next < 0) {
        cnt[has][i] = 1;
        decr[has][i] = next;
      } else {
        cnt[has][i] = 1 + cnt[has][next];
        decr[has][i] = decr[has][next];
      }
    }
  }
  int left = n / mod;
  int right = n % mod;
  long long int ans = 0;
  while (left >= 0) {
    int has = val[left];
    ans += cnt[has][right];
    right = mod + decr[has][right];
    left--;
  }
  cout << ans << endl;
}
