#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long neg = 1, num = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') neg = -1;
  for (; isdigit(c); c = getchar()) num = (num << 1) + (num << 3) + c - '0';
  return neg * num;
}
long long n;
map<long long, long long> f;
inline long long dfs(long long n) {
  if (n == 0) return f[n] = 0;
  if (f.count(n)) return f[n];
  long long res = (1ll << 60), tmp = n;
  while (tmp) {
    if (tmp % 10 != 0) res = min(res, dfs(n - tmp % 10) + 1);
    tmp /= 10;
  }
  return f[n] = res;
}
signed main() {
  n = read();
  cout << dfs(n);
  return 0;
}
