#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > dp;
pair<long long, int> solve(long long n, int d) {
  auto x = make_pair(n, d);
  if (dp.count(x)) return dp[x];
  if (n < 10) return dp[x] = make_pair(1LL, max(0, d - (int)n));
  long long p = 1, tmp = n;
  while (tmp >= 10) p *= 10, tmp /= 10;
  auto u = solve(n - tmp * p, max(d, (int)tmp));
  auto v = solve(tmp * p - u.second, d);
  return dp[x] = make_pair(u.first + v.first, v.second);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  cout << (n ? solve(n, 0).first : 0LL) << endl;
}
