#include <bits/stdc++.h>
using namespace std;
int n, x, dp[1000001];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    dp[i] = 1e9, x = i;
    while (x > 0) dp[i] = min(dp[i], dp[i - x % 10] + 1), x /= 10;
  }
  printf("%d", dp[n]);
}
