#include <bits/stdc++.h>
using namespace std;
long long n, f[20][10][10], b[20], num[20][10][10];
int f1(long long n) {
  int ans = 0;
  while (n) ans++, n /= 10;
  return ans;
}
int main() {
  cin >> n;
  int len = f1(n);
  if (len <= 1) {
    printf("%d\n", len);
    return 0;
  }
  b[1] = 1;
  for (int i = 2; i <= len; i++) b[i] = b[i - 1] * 10;
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j <= 9; j++)
      if (i > j) {
        num[1][i][j] = j - i + 10;
        f[1][i][j] = 1;
      } else {
        num[1][i][j] = 10 - i;
        f[1][i][j] = 2;
      }
  for (int k = 2; k <= len; k++)
    for (int i = 0; i <= 9; i++)
      for (int j = 0; j <= 9; j++) {
        int t = j;
        f[k][i][j] = 0;
        for (int z = 9; z >= 0; z--) {
          f[k][i][j] += f[k - 1][max(z, i)][t];
          t = num[k - 1][max(z, i)][t];
        }
        num[k][i][j] = t;
      }
  long long ans = 0;
  int t = n % 10;
  while (n) {
    for (int i = 2; i <= len; i++)
      if (b[i] <= n) {
        int Max = 0;
        for (int j = len; j > i; j--) Max = max(Max, (int)((n / b[j]) % 10));
        for (int j = (n / b[i]) % 10; j >= 0; j--) {
          ans += f[i - 1][max(Max, j)][t];
          t = num[i - 1][max(Max, j)][t];
          n -= n % b[i];
          n = n - 10 + t;
        }
      }
  }
  ans--;
  cout << ans << endl;
  return 0;
}
