#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
map<pair<long long, long long>, pair<long long, long long> > f;
pair<long long, long long> dfs(long long x, long long y) {
  if (x == 0) return make_pair(x || y, -y);
  if (x < 10) return make_pair(1LL, x - max(x, y));
  if (f.count({x, y})) return f[{x, y}];
  long long ans = 0, p = 1;
  while (p * 10 <= x) p *= 10;
  pair<long long, long long> r = dfs(x % p, max(y, x / p));
  pair<long long, long long> b = dfs(x / p * p + r.second, y);
  ans = r.first + b.first;
  return f[{x, y}] = make_pair(ans, b.second);
}
void work() {
  long long n;
  cin >> n;
  cout << dfs(n, 0).first << endl;
}
int main() {
  work();
  return 0;
}
