#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
const long long int INF = 2e17;
int d[2000000][10], to[2000000][10], mil = 1e6;
int main() {
  long long int n;
  cin >> n;
  memset(d, 0, sizeof d);
  memset(to, 0, sizeof to);
  for (long long int i = 1; i < 2000000; i++) {
    long long int maxi = 0, temp = i;
    while (temp > 0) {
      maxi = max(maxi, temp % 10);
      temp /= 10;
    }
    for (long long int j = 0; j < 10; j++) {
      long long int us = max(j, maxi);
      if (us >= i) {
        to[i][j] = i - us;
        d[i][j] = 1;
      } else {
        d[i][j] = d[i - us][j] + 1;
        to[i][j] = to[i - us][j];
      }
    }
  }
  long long int f = 0, s = 0, temp = n, dec = 1;
  for (long long int i = 0; i < 6; i++) {
    if (!temp) break;
    s += (temp % 10) * dec;
    dec *= 10;
    temp /= 10;
  }
  dec = 1;
  while (temp) {
    f += (temp % 10) * dec;
    dec *= 10;
    temp /= 10;
  }
  long long int ans = 0;
  while (true) {
    long long int now = 0;
    temp = f;
    while (temp) {
      now = max(now, temp % 10);
      temp /= 10;
    }
    ans += d[s][now];
    s = to[s][now];
    if (!s && f) {
      ans++;
      s -= now;
    } else if (!s && !f)
      break;
    s += mil;
    f--;
  }
  cout << ans;
}
