#include <bits/stdc++.h>
using namespace std;
long long n;
map<pair<long long, int>, pair<long long, int> > A;
pair<long long, int> Solve(long long x, int y) {
  pair<long long, int> now = make_pair(x, y), ans;
  if (A.count(now)) return A[now];
  if (x < 10) return A[now] = make_pair(x || y, x - max((int)x, y));
  long long tmp = x / 10, t = 1;
  for (; tmp; tmp /= 10, t *= 10)
    ;
  pair<long long, int> t1 = Solve(x % t, max((long long)y, x / t));
  pair<long long, int> t2 = Solve(x - x % t + t1.second, y);
  return A[now] = make_pair(t1.first + t2.first, t2.second);
}
int main() {
  scanf("%I64d", &n);
  printf("%I64d\n", Solve(n, 0).first);
  return 0;
}
