#include <bits/stdc++.h>
using namespace std;
const long long Ten18 = 1000000000000000000LL;
long long N;
map<long long, pair<long long, long long> > f[10];
long long getMo(long long x) {
  long long res = 1;
  while (res < Ten18 && res * 10 <= x) res *= 10;
  return res;
}
pair<long long, long long> dp(long long mx, long long now) {
  if (now == 0 && mx == 0) return pair<long long, long long>(0, 0);
  if (now < 10) return pair<long long, long long>(1, now - max(now, mx));
  if (f[mx].count(now)) return f[mx][now];
  pair<long long, long long> ans(0, 0);
  long long tmp = now;
  while (now > 0) {
    long long mo = getMo(now);
    long long head = now / mo, trail = now % mo;
    pair<long long, long long> nxt = dp(max(mx, head), trail);
    now = now - now % mo + nxt.second;
    ans.first += nxt.first;
  }
  ans.second = now;
  return f[mx][tmp] = ans;
}
int main() {
  cin >> N;
  for (int i = 0; i < 10; ++i) f[i].clear();
  cout << dp(0, N).first << endl;
  return 0;
}
