#include <bits/stdc++.h>
using namespace std;
const int Maxn = 10000005;
long long n;
map<pair<long long, int>, pair<long long, int> > Ans;
pair<long long, int> dp(long long x, int y) {
  if (Ans.count(make_pair(x, y))) return Ans[make_pair(x, y)];
  pair<long long, int> now = make_pair(x, y);
  if (x < 10) return Ans[now] = make_pair(x || y, x - max((int)x, y));
  long long mod = 1;
  while (mod <= x / 10) mod *= (long long)10;
  int maxDig = x / mod;
  pair<long long, int> part1 = dp(x % mod, max(maxDig, y));
  pair<long long, int> part2 = dp(x - x % mod + part1.second, y);
  return Ans[now] = make_pair(part1.first + part2.first, part2.second);
}
inline void solve() {
  scanf("%I64d", &n);
  long long Ans = dp(n, 0).first;
  printf("%I64d\n", Ans);
}
int main() {
  solve();
  return 0;
}
