#include <bits/stdc++.h>
using namespace std;
inline long long Readll() {
  long long ret = 0;
  int f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch >= 0 && (ch < '0' || ch > '9'));
  while (ch >= '0' && ch <= '9') {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret * f;
}
void open() {
  freopen("number.in", "r", stdin);
  freopen("number.out", "w", stdout);
}
void close() {
  fclose(stdin);
  fclose(stdout);
}
long long pw[20];
long long n;
long long cnt;
struct cs {
  int bf;
  int LG;
  long long num;
  cs() {}
  cs(int bf, int LG, long long num) : bf(bf), LG(LG), num(num) {}
};
bool operator<(cs a, cs b) {
  if (a.bf != b.bf) return a.bf < b.bf;
  if (a.LG != b.LG) return a.LG < b.LG;
  return a.num < b.num;
}
map<cs, pair<int, long long> > M;
inline int id(long long u, int p) { return (u / pw[p]) % 10; }
inline long long cut(long long u, int p) { return u - id(u, p) * pw[p]; }
void init() { n = Readll(); }
pair<int, long long> calc(int bf, int LG, long long num) {
  if (LG == 1)
    return make_pair(num - max(num, 1ll * bf), max(num, 1ll * bf) != 0);
  cs now = cs(bf, LG, num);
  if (M.count(now)) return M[now];
  int high = id(num, LG - 1);
  pair<int, long long> ret;
  if (high) {
    int new_bf = max(bf, high);
    long long new_num = cut(num, LG - 1);
    pair<int, long long> t1 = calc(new_bf, LG - 1, new_num);
    if (t1.first == 0) {
      t1.first -= new_bf;
      t1.second++;
    }
    pair<int, long long> t2 = calc(bf, LG, high * pw[LG - 1] + t1.first);
    ret.first = t2.first;
    ret.second = t1.second + t2.second;
  } else
    ret = calc(bf, LG - 1, num);
  M[now] = ret;
  return ret;
}
int main() {
  int _ = 0;
  pw[0] = 1;
  for (int i = (1), i_END_ = (18); i <= i_END_; i++) pw[i] = pw[i - 1] * 10;
  init();
  long long t = n;
  int LG = 0;
  while (t) {
    LG++;
    t /= 10;
  }
  if (n)
    cout << calc(0, LG, n).second << endl;
  else
    cout << 0 << endl;
  close();
  return 0;
}
