#include <bits/stdc++.h>
template <class T>
inline void chkmax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class T>
inline void chkmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <class T>
inline void read(T &x) {
  char c;
  int f = 1;
  x = 0;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    f = -1;
  else
    x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= f;
}
static int outn;
static char out[(int)2e7];
template <class T>
inline void write(T x) {
  if (x < 0) out[outn++] = '-', x = -x;
  if (x) {
    static int tmpn;
    static char tmp[20];
    tmpn = 0;
    while (x) tmp[tmpn++] = x % 10 + '0', x /= 10;
    while (tmpn) out[outn++] = tmp[--tmpn];
  } else
    out[outn++] = '0';
}
const int N = 1e6;
long long n;
std::map<std::pair<long long, int>, std::pair<long long, int> > f;
std::pair<long long, int> solve(std::pair<long long, int> g) {
  if (!g.first) return std::make_pair(0, 0);
  if (g.first < 10) {
    std::pair<long long, int> ret = std::pair<long long, int>(1, 0);
    if (g.second > g.first) ret.second = g.second - g.first;
    return ret;
  }
  if (f.count(g)) return f[g];
  std::pair<long long, int> &ret = f[g];
  long long x = 1;
  while (x <= g.first / 10) x *= 10;
  for (int i = g.first / x; i >= 0; --i) {
    long long first = g.first % x;
    int second = std::max(i, g.second);
    std::pair<long long, int> h =
        solve(std::pair<long long, int>(first, second));
    g.first -= first, ret.first += h.first;
    if (h.second > 0)
      g.first -= h.second;
    else {
      g.first -= second;
      if (second > 0) ret.first++;
    }
  }
  ret.second = -g.first;
  return ret;
}
int main() {
  read(n);
  std::cout << solve(std::make_pair(n, 0)).first << std::endl;
  return 0;
}
