#include <bits/stdc++.h>
using namespace std;
long long a[20];
long long b[20][10][10];
long long c[20][10][10];
long long dp(long long n, int p) {
  long long n0 = n;
  long long ans = 0;
  while (n >= 10) {
    long long m = n;
    long long e = 0;
    while ((m + 10) % (a[e] * 10) < 10) e++;
    if (e == 1 || a[e] >= n) {
      long long m = n;
      int k = 0;
      while (m != 0) {
        if (m % 10 >= k) k = m % 10;
        m = m / 10;
      }
      ans += 1;
      if (p < k)
        n -= k;
      else
        n -= p;
      continue;
    }
    int i = 0;
    int k = 0;
    for (i; m != 0; i++) {
      if (i >= e && m % 10 >= k) k = m % 10;
      m = m / 10;
    }
    if (k < p) k = p;
    if (b[e][(n + 10) % a[e]][k] == -1) {
      dp(n % a[e], k);
    }
    ans += b[e][(n + 10) % a[e]][k];
    n = n / a[e] * a[e] + c[e][(n + 10) % a[e]][k];
  }
  long long e = 0;
  while ((n0 + 10) % (a[e] * 10) < 10) e++;
  if (a[e] > n0) {
    b[e][(n0 + 10) % a[e]][p] = ans;
    c[e][(n0 + 10) % a[e]][p] = n;
  }
  return ans;
}
int main() {
  a[0] = 1;
  for (int i = 1; i <= 18; i++) a[i] = a[i - 1] * 10;
  for (int i = 0; i < 20; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 0; k < 10; k++) {
        b[i][j][k] = -1;
        c[i][j][k] = -1;
      }
  long long n;
  cin >> n;
  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << dp(n, 0) + 1 << endl;
  return 0;
}
