#include <bits/stdc++.h>
using namespace std;
pair<long long, int> dp[20][10][10 + 2];
int md(long long n) {
  int r = 0;
  while (n) r = max(r, (int)(n % 10)), n /= 10;
  return r;
}
long long brute(long long n) {
  int r = 0;
  while (n) n -= md(n), r++;
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  for (int len = (int)(1), _n = (int)(20); len < _n; len++)
    for (int mx = 0, _n = (int)(10); mx < _n; mx++)
      for (int k = (int)(1), _n = (int)(11); k < _n; k++) {
        long long cnt = 0;
        int nk = k;
        if (len == 1) {
          nk = 10 - nk;
          if (nk == 0 && mx == 0) {
            dp[len][mx][k] = make_pair(0, 0);
            continue;
          }
          nk -= max(nk, mx);
          nk = -nk;
          if (nk == 0 && mx)
            dp[len][mx][k] = make_pair(2, mx);
          else
            dp[len][mx][k] = make_pair(1, nk);
          continue;
        }
        for (int i = (int)(10), _x = (int)(0); i-- > _x;)
          cnt += dp[len - 1][max(mx, i)][nk].first,
              nk = dp[len - 1][max(mx, i)][nk].second;
        dp[len][mx][k] = make_pair(cnt, nk);
      }
  long long n;
  cin >> n;
  long long ans = 0;
  long long p10 = 10;
  for (int len = (int)(1), _n = (int)(18); len < _n; len++) {
    if (!n) break;
    int mx = md(n / p10 / 10);
    int id = n / p10 % 10;
    int k = 10 - n % 10;
    for (int i = (int)(id + 1), _x = (int)(0); i-- > _x;)
      ans += dp[len][max(mx, i)][k].first, k = dp[len][max(mx, i)][k].second;
    p10 *= 10;
    n = n / p10 * p10 - k;
  }
  cout << ans << endl;
  {
    int _;
    cin >> _;
    return 0;
  }
}
