#include <bits/stdc++.h>
using namespace std;
long long dp[1000010];
bool f2(long long val, int dig) {
  while (val) {
    if (val % 10 == dig) {
      return true;
    }
    val /= 10;
  }
  return false;
}
long long f(long long val) {
  if (!val)
    return 0;
  else if (dp[val] != -1)
    return dp[val];
  long long ret = 1000000000, temp;
  for (int i = 1; i <= 9; i++) {
    if (f2(val, i)) {
      temp = 1 + f(val - i);
      ret = min(ret, temp);
    }
  }
  return dp[val] = ret;
}
int main() {
  memset(dp, -1, sizeof(dp));
  long long n;
  cin >> n;
  printf("%lld\n", f(n));
  return 0;
}
