#include <bits/stdc++.h>
using namespace std;
int dp[1000010], vis[10];
void Init() {
  for (int i = 1; i <= 1000010 - 1; i++) dp[i] = 1 << 30;
  for (int i = 1; i <= 1000010 - 1; i++) {
    memset(vis, 0, sizeof(vis));
    int ii = i;
    while (i) {
      vis[i % 10] = 1;
      i /= 10;
    }
    for (int j = 0; j <= 9; j++) {
      if (vis[j]) dp[ii] = min(dp[ii], dp[ii - j] + 1);
    }
    i = ii;
  }
}
int main() {
  Init();
  int n;
  scanf("%d", &n);
  printf("%d\n", dp[n]);
  return 0;
}
