#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int MAXN = 100000 * 3 + 10, MAXL = 10;
map<long long, pair<long long, long long> > f[MAXL];
long long n;
pair<long long, long long> DFS(long long n, int Maxdigt) {
  if (n == 0 && Maxdigt == 0) return make_pair(0, 0);
  if (n < 10) return make_pair(1LL, -(n - max((long long)Maxdigt, n)));
  if (f[Maxdigt].find(n) != f[Maxdigt].end()) return f[Maxdigt][n];
  long long Pow = 1, N = n;
  for (; Pow <= N; Pow *= 10)
    ;
  Pow /= 10;
  pair<long long, long long> CC = make_pair(0, 0);
  while (N > 0) {
    long long k = N / Pow;
    pair<long long, long long> NC = DFS(N % Pow, max(k, (long long)Maxdigt));
    CC.first += NC.first;
    N -= N % Pow + NC.second;
  }
  CC.second = -N;
  f[Maxdigt][n] = CC;
  return CC;
}
int main() {
  cin >> n;
  cout << DFS(n, 0).first << endl;
  fclose(stdin);
  fclose(stdout);
  return 0;
}
