#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int dp[1000002][10], to[1000002][10];
int mmax[1000002];
int main() {
  for (int i = 1; i <= 1000000; i++) mmax[i] = max(mmax[i / 10], i % 10);
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) dp[i][j] = 0, to[i][j] = i;
  for (int i = 10; i <= 1000000; i++) {
    for (int j = 0; j <= mmax[i]; j++)
      dp[i][j] = dp[i - mmax[i]][j] + 1, to[i][j] = to[i - mmax[i]][j];
    for (int j = mmax[i] + 1; j < 10; j++)
      dp[i][j] = dp[i - j][j] + 1, to[i][j] = to[i - j][j];
  }
  long long n;
  while (~scanf("%lld", &n)) {
    long long ans = 0;
    while (n >= 1000000) {
      int w = n % 1000000, x = n / 1000000, k = mmax[x];
      ans += dp[w][k] + 1;
      if (k > to[w][k])
        n = x * 1000000LL - k + to[w][k];
      else
        ans++, n = x * 1000000LL - k;
    }
    if (!n)
      puts("0");
    else
      printf("%lld\n", ans + dp[n][0] + 1);
  }
}
