#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
int dis[10][maxn + 5], num[10][maxn + 5];
inline int get_md(int n) {
  int res = 0;
  while (n) {
    res = max(res, n % 10);
    n /= 10;
  }
  return res;
}
int main() {
  int i, j;
  for (i = 0; i < 10; ++i) {
    for (j = 0; j < i; ++j) {
      dis[i][j] = 1;
      num[i][j] = j - i;
    }
    for (j = i; j < maxn; ++j) {
      int sub = max(i, get_md(j));
      dis[i][j] = dis[i][j - sub] + 1;
      num[i][j] = num[i][j - sub];
    }
  }
  long long n, ans = 0;
  scanf("%I64d", &n);
  if (!n) {
    puts("0");
    return 0;
  }
  while (n) {
    int high = n / maxn, low = n % maxn;
    if (!high) {
      while (low) {
        ans++;
        low -= get_md(low);
      }
      printf("%I64d\n", ans);
      return 0;
    }
    ans += dis[get_md(high)][low];
    n = 1LL * high * maxn + num[get_md(high)][low];
  }
  return 0;
}
