#include <bits/stdc++.h>
using namespace std;
int const N = 1e6 + 1;
int dp[N][10];
int n;
int cal(int x, int i) {
  if (x - i == 0) return 0;
  if (x - i < 0) return 1e9;
  int& ret = dp[x][i];
  if (ret != -1) return ret;
  ret = N;
  x -= i;
  int tmp = x;
  while (tmp != 0) {
    ret = min(ret, cal(x, tmp % 10) + 1);
    tmp /= 10;
  }
  return ret;
}
int main() {
  int res = N;
  scanf("%d", &n);
  memset(dp, -1, sizeof dp);
  int tmp = n;
  while (tmp != 0) {
    int k = cal(n, tmp % 10) + 1;
    res = min(res, k);
    tmp /= 10;
  }
  if (n == 0) res = 0;
  printf("%d\n", res);
  return 0;
}
