#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:666000000")
using namespace std;
const int INF = (1 << 30) - 1;
const long double EPS = 1e-9;
const long double PI = fabs(atan2(0.0, -1.0));
long long n;
void load() { cin >> n; }
const int SZ = 10100;
int sv[SZ];
long long rec(const long long v) {
  if (v < SZ && -1 != sv[v]) return sv[v];
  bool can[10];
  long long p9;
  int prev;
  memset(can, false, sizeof(can));
  {
    long long p = 1;
    long long tmp = v;
    int prev_tmp = -1;
    while (tmp != 0) {
      can[tmp % 10] = true;
      if (9 == tmp % 10) {
        p9 = p;
        prev = prev_tmp;
      }
      prev_tmp = tmp % 10;
      tmp /= 10;
      p *= 10;
    }
  }
  if (v >= SZ) {
    if (can[9] && p9 > 10 && 0 != prev) {
      long long cnt = prev * (p9 / 10) / 9;
      return cnt + rec(v - cnt * 9);
    }
    for (int i = 9; i >= 1; i--)
      if (can[i]) return 1 + rec(v - i);
  }
  long long res = LLONG_MAX;
  for (int i = 1; i <= 9; i++)
    if (can[i]) res = min(res, 1 + rec(v - i));
  if (v < SZ) sv[v] = res;
  return res;
}
void solve() {
  memset(sv, -1, sizeof(sv));
  sv[0] = 0;
  long long res = rec(n);
  cout << res;
}
int main() {
  load();
  solve();
  return 0;
}
