#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:124777216")
using namespace std;
pair<int, int> dp[1000100][10];
int prep[1000100];
pair<int, int> r(int p, int val) {
  if (p < 0) return make_pair(p, 0);
  if ((p == 0) && (val == 0)) return make_pair(p, 0);
  if (dp[p][val].second != -1) return dp[p][val];
  int max1 = max(val, prep[p]);
  pair<int, int> c = r(p - max1, val);
  c.second++;
  return dp[p][val] = c;
}
int main() {
  for (int i = (0); i < (1000100); ++i)
    for (int j = (0); j < (10); ++j) dp[i][j].second = -1;
  for (int i = (1); i < (1000010); ++i) {
    int c = i;
    while (c) {
      prep[i] = max(prep[i], c % 10);
      c /= 10;
    }
  }
  long long c;
  cin >> c;
  long long res = 0;
  while (c > 0) {
    int v = c % 1000000;
    int k = c / 1000000;
    if (v == 0) {
      v = 1000000 - prep[k];
      res++;
      k--;
      c--;
    }
    int val = prep[k];
    pair<int, int> now = r(v, val);
    c -= v;
    c += now.first;
    res += now.second;
  }
  cout << res << endl;
  return 0;
}
