#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, pair<long long, long long> > mp;
pair<long long, long long> solve(long long N, long long mxd) {
  if (N == 0 && mxd == 0) return {0LL, 0LL};
  if (N < 10) {
    if (mxd == 0) return {1LL, 0LL};
    if (mxd > N) return {1LL, N - mxd};
    return {2LL, -mxd};
  }
  long long initN = N;
  if (mp.count({N, mxd})) return mp[{N, mxd}];
  long long p10 = 1;
  while (p10 <= N / 10LL) p10 *= 10LL;
  long long cif = N / p10;
  long long rem = N % p10;
  pair<long long, long long> ans1 = solve(N % p10, max(cif, mxd));
  cif--;
  if (cif < 0) {
    mp[{initN, mxd}] = ans1;
    return ans1;
  }
  N -= (N % p10);
  N += ans1.second;
  pair<long long, long long> ans2 = solve(N, mxd);
  pair<long long, long long> ans;
  ans.first = ans1.first + ans2.first;
  ans.second = ans2.second;
  mp[{initN, mxd}] = ans;
  return ans;
}
int main() {
  long long N;
  scanf("%I64d", &N);
  auto ans = solve(N, 0);
  printf("%I64d\n", ans.first);
  return 0;
}
