#include <bits/stdc++.h>
using namespace std;
pair<long long, int> operator+(pair<long long, int> p, long long x) {
  return make_pair(p.first + x, p.second);
}
long long n, _10Pow[20];
pair<long long, int> dp[10][20][10][10];
pair<long long, int> get(int num, int len, int LS, int MX) {
  if (num == 0) return {0, LS};
  if (dp[num][len][LS][MX].first + 1) return dp[num][len][LS][MX];
  int r = max({MX, num, LS});
  if (r == LS) return dp[num][len][LS][MX] = get(num, len, 0, MX) + 1;
  if (len == 2) {
    int k = 10 * num + LS;
    k -= r;
    if (k < 10) return dp[num][len][LS][MX] = {1, k};
    return dp[num][len][LS][MX] = get(k / 10, 2, k % 10, MX) + 1;
  }
  long long k = (num * _10Pow[len - 1] + LS - r) % _10Pow[len - 2];
  pair<long long, int> p = get(9, len - 1, k % 9, max(MX, num - 1)) + k / 9 + 1;
  if (num > 1)
    return dp[num][len][LS][MX] = get(num - 1, len, p.second, MX) + p.first;
  return dp[num][len][LS][MX] = p;
}
int main() {
  cin >> n;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 20; j++)
      for (int k = 0; k < 10; k++)
        for (int l = 0; l < 10; l++) dp[i][j][k][l].first = -1;
  _10Pow[0] = 1;
  for (int i = 1; i < 19; i++) _10Pow[i] = _10Pow[i - 1] * 10LL;
  if (n == 0) return cout << "0\n", 0;
  if (n < 10) return cout << "1\n", 0;
  long long x = n;
  vector<int> v;
  while (x) v.push_back(x % 10), x /= 10;
  vector<int> mx(v.size());
  mx.back() = 0;
  for (int i = v.size() - 2; i >= 0; i--) mx[i] = max(mx[i + 1], v[i + 1]);
  long long ans = 0;
  x = v[0];
  pair<long long, int> p;
  for (int i = 1; i < v.size(); i++) {
    p = get(v[i], i + 1, x, mx[i]);
    ans += p.first;
    x = p.second;
  }
  if (x) ans++;
  printf("%I64d\n", ans);
  return 0;
}
