#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
long long cost[N][10], step[N][10], n;
int getMax(int x) {
  int ret = 0;
  while (x) {
    ret = max(ret, int(x % 10));
    x /= 10;
  }
  return ret;
}
void init() {
  for (int i = 0; i < N; i++) {
    int c = getMax(i);
    for (int j = 0; j < 10; j++) {
      int v = max(j, c);
      if (i < v) {
        step[i][j] = 1;
        cost[i][j] = v;
      } else {
        step[i][j] = step[i - v][j] + 1;
        cost[i][j] = cost[i - v][j] + v;
      }
    }
  }
}
int main() {
  init();
  scanf("%lld", &n);
  long long ans = 0;
  while (n >= N) {
    int j = getMax(n / N);
    ans += step[n % N][j];
    n -= cost[n % N][j];
  }
  while (n > 0) {
    int j = getMax(n);
    ans += 1;
    n -= j;
  }
  printf("%lld\n", ans);
  return 0;
}
