#include <bits/stdc++.h>
using namespace std;
long long tenpow[20];
int maxdig(long long n, int md) {
  int u = md;
  int p = 0;
  while (n) {
    u = max(u, int(n % 10));
    n /= 10;
    ++p;
  }
  return u;
}
int predo[1000001][10];
int predorem[1000001][10];
void smallsol(int n, int md) {
  if (predo[n][md] >= 0) return;
  if (n == 0) {
    predo[n][md] = 0;
    predorem[n][md] = 0;
    return;
  }
  if (md > n) {
    predo[n][md] = 0;
    predorem[n][md] = n;
    return;
  }
  int u = maxdig(n, md);
  smallsol(n - u, md);
  predo[n][md] = predo[n - u][md] + 1;
  predorem[n][md] = predorem[n - u][md];
}
long long solvebig(long long n) {
  long long c = 0;
  long long up = n / 1000000;
  long long dw = n % 1000000;
  while (up) {
    int u = maxdig(up, 0);
    smallsol(dw, u);
    c += predo[dw][u];
    dw = predorem[dw][u];
    n = up * 1000000 + dw;
    u = maxdig(n, 0);
    n -= u;
    ++c;
    up = n / 1000000;
    dw = n % 1000000;
  }
  smallsol(n, 0);
  return c + predo[n][0];
}
int main() {
  tenpow[0] = 1;
  for (int i = 1; i < 20; ++i) tenpow[i] = tenpow[i - 1] * 10;
  memset(predo, -1, sizeof(predo));
  long long n;
  while (cin >> n) {
    long long foo = solvebig(n);
    cout << foo << endl;
  }
  return 0;
}
