#include <bits/stdc++.h>
using namespace std;
long long v[10][20][10];
int r[10][20][10];
void init() {
  v[0][0][0] = r[0][0][0] = 0;
  for (int j = 1; j < 10; ++j) {
    v[0][0][j] = 1;
    r[0][0][j] = 0;
  }
  for (int j = 0; j < 10; ++j)
    for (int i = 1; i < 10; ++i) {
      if (i > j) {
        v[i][0][j] = 1;
        r[i][0][j] = j - i + 10;
      } else {
        v[i][0][j] = 2;
        r[i][0][j] = 10 - i;
      }
    }
  for (int k = 1; k < 18; ++k)
    for (int j = 0; j < 10; ++j)
      for (int i = 0; i < 10; ++i) {
        int p = j;
        v[i][k][j] = 0;
        for (int l = 9; l >= 0; --l) {
          int t = max(l, i);
          v[i][k][j] += v[t][k - 1][p];
          p = r[t][k - 1][p];
        }
        r[i][k][j] = p;
      }
}
long long f(long long pre, int c, int p) {
  if (pre == 0) return v[0][c][p];
  int u = pre % 10;
  pre /= 10;
  if (u == 9) return f(pre, c + 1, p);
  int i = 0;
  long long tmp = pre;
  while (tmp) {
    i = max((long long)i, tmp % 10);
    tmp /= 10;
  }
  long long res = 0;
  for (int l = u; l >= 0; --l) {
    int t = max(l, i);
    res += v[t][c][p];
    p = r[t][c][p];
  }
  if (pre > 0) res += f(pre - 1, c + 1, p);
  return res;
}
int main() {
  init();
  long long n;
  cin >> n;
  cout << f(n / 10, 0, n % 10) << endl;
  return 0;
}
