#include <bits/stdc++.h>
using namespace std;
long long cf10[20];
pair<long long, int> f[10][20][10];
pair<long long, int> dp(int x, long long n) {
  if (n < 10) {
    if (n >= x)
      return make_pair(2, -x);
    else
      return make_pair(1, n - x);
  }
  int e = 18;
  while (cf10[e] > n) e--;
  pair<long long, int> ret = dp(max(x, (int)(n / cf10[e])), n % cf10[e]);
  long long ans = ret.first;
  int offset = ret.second;
  for (int i = n / cf10[e] - 1; i >= 0; i--) {
    ret = f[max(x, i)][e - 1][offset + 10];
    ans += ret.first;
    offset = ret.second;
  }
  return make_pair(ans, offset);
}
int main() {
  cf10[0] = 1;
  for (int i = 1; i < 19; i++) {
    cf10[i] = 10 * cf10[i - 1];
  }
  for (int j = 0; j < 19; j++)
    for (int i = 0; i < 10; i++)
      for (int k = 0; k < 10; k++) f[i][j][k] = dp(i, cf10[j] * 10 - 10 + k);
  long long n;
  cin >> n;
  if (n == 0)
    cout << 0 << endl;
  else
    cout << dp(0, n).first - 1 << endl;
  return 0;
}
