#include <bits/stdc++.h>
using namespace std;
long long n, Power[20];
map<pair<long long, int>, pair<long long, int> > dp;
pair<long long, int> Dp(long long n, int dep, int m) {
  if (dep == 1) return make_pair(1LL, (int)n - max((int)n, m));
  if (n < Power[dep - 1]) return Dp(n, dep - 1, m);
  pair<long long, int> &ans = dp[make_pair(n, m)];
  if (ans.first) return ans;
  pair<long long, int> tmp =
      Dp(n % Power[dep - 1], dep - 1, max(m, (int)(n / Power[dep - 1])));
  long long newn = n - n % Power[dep - 1] + tmp.second;
  pair<long long, int> v = Dp(newn, dep, m);
  ans = make_pair(tmp.first + v.first, v.second);
  return ans;
}
long long work() {
  Power[0] = 1;
  for (int i = 1; i <= 18; ++i) Power[i] = Power[i - 1] * 10;
  int cnt = 0;
  for (long long i = n; i; i /= 10) ++cnt;
  if (n == 0) return 0;
  return Dp(n, cnt, 0).first;
}
int main() {
  cin >> n;
  cout << work() << endl;
  return 0;
}
