#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
inline long long countSetBit(long long i) {
  i = i - ((i >> 1) & 0x55555555);
  i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
  i = (i + (i >> 4)) & 0x0f0f0f0f;
  i = i + (i >> 8);
  i = i + (i >> 16);
  return i & 0x3f;
}
inline void set_bit(long long &n, long long b) { n |= 1 << b; }
inline void unset_bit(long long &n, long long b) { n &= ~(1 << b); }
inline void toggle_bit(long long &n, long long b) { n ^= 1 << b; }
inline void swap(long long &a, long long &b) {
  a ^= b;
  b ^= a;
  a ^= b;
}
inline int digitContain(long long a) {
  return (long long)(floor(log10(a)) + 1);
}
inline bool isPoweroftwo(long long x) { return x && (!(x & (x - 1))); }
inline long long ipow(long long base, unsigned long long exp) {
  long long result = 1;
  while (exp) {
    if (exp & 1) result *= base;
    exp >>= 1;
    if (!exp) break;
    base *= base;
  }
  return result;
}
inline long long msd(long long n) {
  return ipow(10, (long double)(log10(n) - floor(log10(n))));
}
inline void fast_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void solve();
int main() {
  fast_io();
  for (auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);
       blockTime.second;
       fprintf(stderr, "%s: %lld ms\n", "Runtime",
               chrono::duration_cast<chrono::milliseconds>(
                   chrono::high_resolution_clock::now() - blockTime.first)
                   .count()),
            fflush(stderr), blockTime.second = false) {
    solve();
  }
  return 0;
}
map<pair<unsigned long long, unsigned long long>,
    pair<unsigned long long, unsigned long long> >
    dp;
pair<unsigned long long, unsigned long long> dfs(
    pair<unsigned long long, unsigned long long> in) {
  unsigned long long cur = 1, res;
  if (in.second < 10)
    return make_pair(in.first || in.second,
                     in.second - max(in.first, in.second));
  if (dp.find(in) != dp.end()) return dp[in];
  while (cur <= in.second / 10) cur *= 10;
  pair<unsigned long long, unsigned long long> mi =
      dfs(make_pair(max(in.first, in.second / cur), in.second % cur));
  res = mi.first;
  mi = dfs(make_pair(in.first, in.second / cur * cur + mi.second));
  return dp[in] = make_pair(mi.first + res, mi.second);
}
void solve() {
  unsigned long long x;
  cin >> x;
  cout << dfs(make_pair(0, x)).first << '\n';
}
