#include <bits/stdc++.h>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
using namespace ::std;
const int maxn = 1e5 + 500;
const int inf = 1e9 + 800;
const int mod = 1e9 + 7;
map<pair<string, int>, pair<string, long long> > ml;
pair<string, long long> KojChej(string sn, const int y) {
  string rn = sn;
  if (ml.count(make_pair(sn, y)) != 0) {
    return ml[make_pair(sn, y)];
  }
  if (sn.size() == 1) {
    int n = sn[0] - '0';
    int res = 0;
    while (n >= 0 && (n != 0 || y != 0)) {
      res++;
      n -= max((int)n, y);
    }
    if (n < 0) n += 10;
    sn[0] = n + '0';
    ml[make_pair(rn, y)] = make_pair(sn, res);
    return make_pair(sn, res);
  }
  int a = sn[0] - '0';
  string b = sn.substr(1, sn.size() - 1);
  long long ans = 0;
  for (int i = a; i >= 0; i--) {
    pair<string, long long> p = KojChej(b, max(i, y));
    ans += p.second;
    b = p.first;
  }
  sn = "9" + b;
  ml[make_pair(rn, y)] = make_pair(sn, ans);
  return make_pair(sn, ans);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string n;
  cin >> n;
  cout << KojChej(n, 0).second;
}
