#include <bits/stdc++.h>
using namespace std;
struct node {
  long long step, res;
};
long long n, c[20];
node dp[11][20][10];
bool vis[11][20][10];
long long l;
long long max(long long a, long long b) { return a > b ? a : b; }
node f(long long i, long long j, long long k) {
  if (vis[i][j][k]) return dp[i][j][k];
  vis[i][j][k] = true;
  node &ret = dp[i][j][k];
  if (j == 1) {
    int nk;
    if (i == 10) {
      nk = max(k, n % 10);
      if (n % 10 >= nk)
        return ret = (node){1, 0};
      else
        return ret = (node){0, n % 10};
    } else {
      nk = max(k, i);
      if (i >= nk)
        return ret = (node){1, 0};
      else
        return ret = (node){0, i};
    }
  } else {
    node ans = (node){0, 0};
    node next;
    long long num, m;
    if (i == 10)
      num = n % c[j];
    else
      num = c[j] - 10 + i;
    m = num;
    while (true) {
      next = f((m == num && i == 10) ? 10 : num % 10, j - 1,
               max(k, num / c[j - 1] % 10));
      ans.step += next.step;
      (num /= c[j - 1]) *= c[j - 1];
      num += next.res;
      while (true) {
        long long nk = max(max(k, num / c[j - 1]), num % 10);
        if (next.res >= nk && num)
          num -= nk, ans.step++, next.res -= nk;
        else
          break;
      }
      if (!num) break;
      long long nk = max(max(k, num / c[j - 1]), num % 10);
      if (num < nk) return ret = (node){ans.step, num};
      if (nk) ans.step++, num -= nk;
    }
    return ret = ans;
  }
}
int main() {
  cin >> n;
  c[0] = 1;
  for (long long i = 1; i < 19; i++) c[i] = c[i - 1] * 10ll;
  c[19] = 9000000000000000000ll;
  for (l = 0; c[l] <= n; l++)
    ;
  if (!n) {
    cout << 0 << endl;
    return 0;
  }
  cout << f(10, l, 0).step << endl;
  return 0;
}
