#include <bits/stdc++.h>
using namespace std;
long long f[20][10][10], g[20][10][10], pw[20], s[20];
int main() {
  for (int j = 0; j <= 9; j++)
    for (int k = 0; k <= 9; k++)
      if (k > j)
        f[0][j][k] = j;
      else
        g[0][j][k] = 1;
  for (int i = 1; i <= 18; i++)
    for (int j = 0; j <= 9; j++)
      for (int k = 0; k <= 9; k++) {
        long long res = 9, now = j;
        for (int l = 9; l >= 0; l--) {
          res += g[i - 1][now][max(l, k)];
          now = l ? (10 + f[i - 1][now][max(l, k)] - max(l, k)) % 10
                  : f[i - 1][now][max(l, k)];
        }
        if (now && now >= k) res++, now = 0, assert(0);
        f[i][j][k] = now, g[i][j][k] = res;
      }
  long long n;
  cin >> n;
  pw[0] = 1;
  for (int i = 1; i <= 18; i++) pw[i] = pw[i - 1] * 10;
  for (int i = 18; i >= 0; i--) s[i] = max(s[i + 1], (n / pw[i] % 10));
  long long res = 0, now, now2 = (n / pw[0] % 10);
  for (int i = 1; s[i]; i++) {
    now = (n / pw[i] % 10) - 1;
    if (now == -1) continue;
    res += now + 1;
    if (now2 >= s[i]) res++, now2 = 0;
    now2 = (10 + now2 - s[i]) % 10;
    while (~now) {
      res += g[i - 1][now2][max(s[i + 1], now)];
      now2 =
          now ? (10 + f[i - 1][now2][max(s[i + 1], now)] - max(s[i + 1], now)) %
                    10
              : f[i - 1][now2][s[i + 1]];
      now--;
    }
  }
  if (now2) res++;
  cout << res;
  return 0;
}
