#include <bits/stdc++.h>
using namespace std;
map<pair<long long unsigned, long long unsigned>,
    pair<long long unsigned, long long unsigned> >
    dp;
long long unsigned n;
void read() {
  cin >> n;
  return;
}
pair<long long unsigned, long long unsigned> find(long long unsigned s,
                                                  long long unsigned mx) {
  if (s <= 9) return make_pair(0, s);
  if (dp.find(make_pair(s, mx)) != dp.end()) return dp[make_pair(s, mx)];
  long long unsigned t, r, m;
  pair<long long unsigned, long long unsigned> &ans = dp[make_pair(s, mx)];
  t = 1;
  while (t * 10 <= s) t *= 10;
  r = s % t;
  s = s / t;
  while (1) {
    m = max(mx, s);
    pair<long long unsigned, long long unsigned> f = find(r, m);
    ans.first += f.first;
    if (s == 0) {
      ans.second = f.second;
      break;
    }
    if (f.second >= m) {
      ans.first += 2;
      r = t - m;
    } else {
      ans.first++;
      r = t - (m - f.second);
    }
    s--;
  }
  return ans;
}
void solve() {
  read();
  pair<long long unsigned, long long unsigned> cvp = find(n, 0);
  cout << cvp.first + !!cvp.second << endl;
  return;
}
int main() {
  solve();
  return 0;
}
