#include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma comment(linker, "/STACK:0x800000")
int dp[1000100];
int mini(int a, int b) {
  if (a < b) return a;
  return b;
}
int main() {
  int i, j, k, l, test, t = 1, n;
  scanf("%d", &n);
  dp[0] = 0;
  for (i = 1; i <= n; i++) {
    int n1 = i;
    dp[i] = (1 << 29);
    while (n1) {
      int now = n1 % 10;
      n1 /= 10;
      if (now > i) continue;
      dp[i] = mini(dp[i], dp[i - now] + 1);
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}
