#include <bits/stdc++.h>
using namespace std;
long long n;
map<pair<long long, long long>, pair<long long, long long> > mp;
pair<long long, long long> dfs(long long n, long long m) {
  if (mp.find(pair<long long, long long>(n, m)) != mp.end())
    return mp[pair<long long, long long>(n, m)];
  if (n < 10)
    return mp[pair<long long, long long>(n, m)] =
               pair<long long, long long>(n || m, n - max(n, m));
  long long p = 1;
  while (p <= n / 10) p *= 10;
  pair<long long, long long> tmp = dfs(n % p, max(n / p, m));
  pair<long long, long long> ans = dfs(n / p * p + tmp.second, m);
  return mp[pair<long long, long long>(n, m)] =
             pair<long long, long long>(tmp.first + ans.first, ans.second);
}
int main() {
  cin >> n;
  cout << dfs(n, 0).first << endl;
  return 0;
}
