#include <bits/stdc++.h>
using namespace std;
struct node {
  long long p, x;
  bool operator<(const node g) const {
    if (p != g.p)
      return p < g.p;
    else
      return x < g.x;
  }
};
map<node, node> f;
node dp(long long x, long long y) {
  if (f[(node){x, y}].p) return f[(node){x, y}];
  if (x < 10) {
    f[(node){x, y}] = (node){x || y, x - max(x, y)};
    return (node){x || y, x - max(x, y)};
  }
  long long t = x / 10, tmp = 1;
  while (t) {
    tmp *= 10;
    t /= 10;
  }
  long long v = max(y, x / tmp);
  node v1 = dp(x % tmp, v);
  node v2 = dp(x - x % tmp + v1.x, y);
  f[(node){x, y}] = (node){v1.p + v2.p, v2.x};
  return (node){v1.p + v2.p, v2.x};
}
int main() {
  long long n;
  cin >> n;
  cout << dp(n, 0).p << endl;
  return 0;
}
