#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
map<pair<long long, int>, pair<long long, int> > d;
pair<long long, int> dfs(long long n, int mx) {
  if (n <= 0) {
    return make_pair(0, -n);
  }
  pair<long long, int> state = make_pair(n, mx);
  if (d.count(state)) return d[state];
  long long st = 1;
  while (st <= n / 10) st *= 10;
  pair<long long, int> res = make_pair(0, 0);
  while (n / st > 0) {
    int nmx = max(mx, int(n / st));
    pair<long long, int> cur = dfs(n % st, nmx);
    res.first += cur.first;
    n -= n % st;
    if (cur.second == 0) {
      n -= nmx;
      res.first++;
    } else {
      n -= cur.second;
    }
  }
  pair<long long, int> low = dfs(n, mx);
  res.first += low.first;
  res.second = low.second;
  return d[state] = res;
}
int main() {
  long long n;
  cin >> n;
  cout << dfs(n, 0).first << endl;
  return 0;
}
