#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9;
int dp[N], S[30], p;
void fenjie(int n) {
  memset(S, 0, sizeof(S));
  while (n) {
    S[p++] = n % 10;
    n = n / 10;
  }
}
void fun() {
  memset(dp, 63, sizeof(dp));
  int i, j;
  dp[0] = 0;
  for (i = 1; i < 10; i++) dp[i] = 1;
  for (i = 10; i < N; i++) {
    p = 0;
    fenjie(i);
    for (j = 0; j < p; j++)
      if (S[j]) dp[i] = min(dp[i], dp[i - S[j]] + 1);
  }
}
int main() {
  int n;
  fun();
  while (scanf("%d", &n) != EOF) printf("%d\n", dp[n]);
  return 0;
}
