#include <bits/stdc++.h>
int dp[1000000 + 1];
int min(int a, int b) { return (a < b ? a : b); }
int power10(int k) {
  if (k == 0) return 1;
  return (10 * power10(k - 1));
}
int go(int n) {
  if (dp[n] != n + 1) return dp[n];
  int res = n + 1;
  int i;
  i = 0;
  while (++i < 8) {
    int digit = (n / power10(i - 1)) % 10;
    if (digit != 0) res = min(res, 1 + go(n - digit));
  }
  return (dp[n] = res);
}
int main() {
  int n, i;
  scanf("%d", &n);
  i = -1;
  while (++i < n + 1) dp[i] = i + 1;
  dp[0] = 0;
  printf("%d", go(n));
}
