#include <bits/stdc++.h>
using namespace std;
int dp[1000010];
map<pair<int, long long>, pair<int, long long> > mp;
long long ten[20];
pair<int, long long> func(int pre, long long N) {
  int i;
  if (N <= 0) return make_pair((int)(-N), 0ll);
  pair<int, long long> st = make_pair(pre, N);
  if (mp.find(st) != mp.end()) return mp[st];
  int a[20];
  long long x = N;
  for ((i) = 0; (i) < (int)(20); (i)++) {
    a[i] = (int)(x % 10);
    x /= 10;
  }
  int maxa = pre;
  for ((i) = 0; (i) < (int)(20); (i)++) maxa = max(maxa, a[i]);
  if (N % 100 <= 90) {
    pair<int, long long> tmp = func(pre, N - maxa);
    return make_pair(tmp.first, tmp.second + 1);
  }
  for (i = 1;; i++)
    if (a[i] != 9) break;
  int e = i;
  int pre2 = pre;
  for (i = e; i < 20; i++) pre2 = max(pre2, a[i]);
  if (N < ten[e]) {
    pair<int, long long> tmp = func(pre, N - maxa);
    return make_pair(tmp.first, tmp.second + 1);
  }
  pair<int, long long> tmp2 = func(pre2, N % ten[e]);
  pair<int, long long> ans = func(pre, N / ten[e] * ten[e] - tmp2.first);
  ans.second += tmp2.second;
  return mp[st] = ans;
}
int main(void) {
  int i;
  ten[0] = 1;
  for (i = 1; i < 20; i++) ten[i] = ten[i - 1] * 10;
  long long N;
  cin >> N;
  cout << func(0, N).second << endl;
  return 0;
}
