#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> d[20][10][10];
pair<long long, long long> solve(int w, int lose, int ma) {
  int i;
  long long tmp, tmp1;
  pair<long long, long long> ans, p;
  if (d[w][lose][ma].first != -1) return d[w][lose][ma];
  if (w == 1) {
    tmp = 10 - lose;
    ans = make_pair(0, 0);
    while ((tmp > 0) || ((tmp == 0) && (ma != 0))) {
      if (ma > tmp)
        tmp -= ma;
      else
        tmp -= tmp;
      ans.first++;
    }
    ans.second = -tmp;
    d[w][lose][ma] = ans;
    return ans;
  } else {
    tmp = 1;
    for (i = 0; i < w; i++) tmp *= 10;
    tmp1 = tmp / 10;
    tmp -= lose;
    ans = make_pair(0, 0);
    while ((tmp > 0) || ((tmp == 0) && (ma != 0))) {
      p = solve(w - 1, tmp1 - tmp % tmp1, (tmp / tmp1 > ma ? tmp / tmp1 : ma));
      ans.first += p.first;
      tmp = tmp / tmp1 * tmp1 - p.second;
    }
    ans.second = -tmp;
    d[w][lose][ma] = ans;
    return ans;
  }
}
int main() {
  int i, l, x, tmp1;
  long long n, tmp, ans;
  char s[100];
  pair<long long, long long> p;
  scanf("%I64d", &n);
  memset(d, -1, sizeof(d));
  tmp = 1;
  ans = 0;
  tmp1 = 0;
  while (1) {
    tmp *= 10;
    tmp1++;
    if (tmp > n) break;
    while (n % (tmp * 10) < tmp * 10 - 10) {
      if (n == 0) break;
      sprintf(s, "%I64d", n);
      l = strlen(s);
      x = 0;
      for (i = 0; i < l - tmp1; i++)
        if (s[i] - '0' > x) x = s[i] - '0';
      p = solve(tmp1, tmp - n % tmp, x);
      ans += p.first;
      n = n / tmp * tmp - p.second;
    }
  }
  while (tmp > 1) {
    while (tmp <= n) {
      sprintf(s, "%I64d", n);
      l = strlen(s);
      x = 0;
      for (i = 0; i < l - tmp1; i++)
        if (s[i] - '0' > x) x = s[i] - '0';
      p = solve(tmp1, tmp - n % tmp, x);
      ans += p.first;
      n = n / tmp * tmp - p.second;
    }
    tmp /= 10;
    tmp1--;
  }
  if (n != 0) {
    ans++;
    n = 0;
  }
  printf("%I64d\n", ans);
}
