#include <bits/stdc++.h>
using namespace std;
const int N = 180000, M = 997807;
struct hashnode {
  int b, c, pre;
  long long a, f, g;
} h[N];
int l = 0, u[M];
void add(long long a, int b, int c, long long f, long long g) {
  int H = (a + b * 137 * c * 373) % M;
  h[++l] = (hashnode){b, c, u[H], a, f, g};
  u[H] = l;
}
pair<long long, long long> qry(long long a, int b, int c) {
  int H = (a + b * 137 * c * 373) % M;
  for (int i = u[H]; i; i = h[i].pre)
    if (h[i].a == a && h[i].b == b && h[i].c == c)
      return make_pair(h[i].f, h[i].g);
  return make_pair(-1, 0);
}
long long pw[19];
pair<long long, long long> f(long long n, int a, int b) {
  if (n == 0) return make_pair(0, 0);
  if (n <= b)
    return make_pair(1, -b);
  else if (a == 0)
    return make_pair(1, -n);
  if (n / pw[a] == 0) return f(n, a - 1, b);
  pair<long long, long long> t = qry(n, a, b), ans = make_pair(0, 0);
  if (t.first != -1) return t;
  long long t1 = n;
  while (n / pw[a] && n > 0) {
    if (n % pw[a] == 0) {
      int t = n / pw[a];
      n -= ((b) > (t) ? (b) : (t)), ans.second -= ((b) > (t) ? (b) : (t)),
          ans.first++;
    }
    t = f(n % pw[a], a - 1, ((b) > (n / pw[a]) ? (b) : (n / pw[a])));
    n += t.second;
    ans.second += t.second, ans.first += t.first;
  }
  add(t1, a, b, ans.first, ans.second);
  return ans;
}
int main() {
  long long n;
  cin >> n;
  pw[0] = 1;
  for (int i = 1; i <= 18; i++) pw[i] = pw[i - 1] * 10;
  cout << f(n, 18, 0).first << endl;
}
