#include <bits/stdc++.h>
using namespace std;
struct node {
  long long step, remain;
  node() { step = -1; }
  node(int step_, int remain_) {
    step = step_;
    remain = remain_;
  }
};
node dp[20][10][11];
long long pw[20];
node solve(int pos, int lm, long long n, bool flag) {
  int state = 10;
  if (!flag) {
    state = n % 10;
  }
  if (dp[pos][lm][state].step != -1) {
    return dp[pos][lm][state];
  }
  if (pos == 0) {
    if (lm > n) {
      dp[pos][lm][state].step = 0;
      dp[pos][lm][state].remain = n;
    } else {
      dp[pos][lm][state].step = 1;
      dp[pos][lm][state].remain = 0;
    }
    return dp[pos][lm][state];
  }
  long long cnt = 0, remain = 0;
  int d = n / pw[pos];
  remain = n % pw[pos];
  while (d >= 0) {
    node nd = solve(pos - 1, max(lm, d), remain, flag);
    flag = false;
    cnt += nd.step;
    remain = nd.remain;
    if (d > 0) {
      remain = nd.remain + pw[pos] - max(lm, d);
      ++cnt;
    }
    --d;
  }
  dp[pos][lm][state].step = cnt;
  dp[pos][lm][state].remain = remain;
  return dp[pos][lm][state];
}
int main() {
  long long n;
  pw[0] = 1;
  for (int i = 1; i < 19; ++i) {
    pw[i] = pw[i - 1] * 10;
  }
  pw[19] = 9000000000000000000ll;
  while (cin >> n) {
    if (n == 0) {
      cout << 0 << endl;
      continue;
    }
    int p = 0;
    while (pw[p] <= n) {
      ++p;
    }
    --p;
    cout << solve(p, 0, n, true).step << endl;
  }
  return 0;
}
