#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6;
vector<long long> maxi(maxn);
vector<vector<long long> > steps(10, vector<long long>(maxn + 1, 0)), state;
long long f(long long x) {
  long long sol = 0;
  while (x) {
    sol = max(sol, x % 10);
    x /= 10;
  }
  return sol;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  state = steps;
  for (long long i = 0; i <= maxn; ++i) maxi[i] = f(i);
  for (long long s = 0; s < 10; ++s) {
    for (long long i = 0; i < 10; ++i) {
      steps[s][i] = 0;
      state[s][i] = i;
    }
    for (long long i = 10; i <= maxn; ++i) {
      long long d = max(s, maxi[i]);
      steps[s][i] = steps[s][i - d] + 1;
      state[s][i] = state[s][i - d];
    }
  }
  long long n, sol = 0;
  cin >> n;
  if (n == 1e12) {
    --n;
    ++sol;
  }
  while (n) {
    long long gore = n / maxn;
    long long dole = n % maxn;
    sol += steps[maxi[gore]][dole];
    dole = state[maxi[gore]][dole];
    if (!dole && !gore) break;
    long long d = max(maxi[gore], maxi[dole]);
    n = gore * maxn + dole;
    n -= d;
    ++sol;
  }
  cout << sol << '\n';
}
