#include <bits/stdc++.h>
using namespace std;
struct node {
  long long sm, num;
  node(long long s = 0, long long n = 0) : sm(s), num(n) {}
  inline int operator<(const node &x) const {
    if (sm != x.sm) return sm < x.sm;
    return num < x.num;
  }
};
map<node, node> mp;
long long n;
node dfs(node x) {
  if (x.num < 10) return node(x.sm || x.num, x.num - max(x.sm, x.num));
  if (mp.count(x)) return mp[x];
  long long p = 1, an = 0;
  while (p <= x.num / 10) p *= 10;
  node C = dfs(node(max(x.sm, x.num / p), x.num % p));
  an += C.sm;
  node Ano = node(x.sm, x.num / p * p + C.num);
  C = dfs(Ano);
  return mp[x] = node(an + C.sm, C.num);
}
void setIO(string a) {
  string in = a + ".in", out = a + ".out";
  freopen(in.c_str(), "r", stdin);
  freopen(out.c_str(), "w", stdout);
}
int main() {
  scanf("%I64d", &n);
  printf("%I64d\n", dfs(node(0, n)).sm);
  return 0;
}
