#include <bits/stdc++.h>
using std::map;
using std::pair;
long long N, Pow[20];
map<std::pair<long long, int>, std::pair<long long, int> > dp;
std::pair<long long, int> DP(long long N, int dep, int m) {
  if (dep == 1) return std::make_pair((1LL), (int(N - std::max(m * 1ll, N))));
  if (N < Pow[dep - 1]) return DP(N, dep - 1, m);
  std::pair<long long, int>& ans = dp[std::make_pair((N), (m))];
  if (ans.first) return ans;
  std::pair<long long, int> tmp =
      DP(N % Pow[dep - 1], dep - 1,
         std::max(m, static_cast<int>(N / Pow[dep - 1])));
  std::pair<long long, int> res = DP(N - N % Pow[dep - 1] + tmp.second, dep, m);
  return ans = std::make_pair((tmp.first + res.first), (res.second));
}
int main() {
  Pow[0] = 1;
  for (int i = 1; i <= 18; i++) Pow[i] = Pow[i - 1] * 10;
  scanf("%I64d", &N);
  long long Other = N;
  int bit = 0;
  for (; Other; Other /= 10) bit++;
  long long Answer = (!N ? 0 : DP(N, bit, 0).first);
  printf("%I64d\n", Answer);
  return 0;
}
