#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100, inf = 1e9;
int dp[maxn][10], dp2[maxn][10];
int fmx(long long n) {
  int mx = 0;
  n /= 1000 * 1000;
  while (n > 0) {
    mx = max(mx, (int)n % 10);
    n /= 10;
  }
  return mx;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, ans = 0;
  cin >> n;
  for (int i = 1; i <= 9; i++)
    for (int j = 0; j <= 9; j++) {
      dp[i][j] = 1;
      dp2[i][j] = i;
    }
  for (int i = 10; i < maxn; i++) {
    for (int j = 0; j <= 9; j++) {
      int x = i;
      int mx = j;
      while (x > 0) {
        mx = max(mx, x % 10);
        x /= 10;
      }
      dp[i][j] = dp[i - mx][j] + 1;
      dp2[i][j] = dp2[i - mx][j];
    }
  }
  while (n > 0) {
    int z = fmx(n);
    int x = n % (1000 * 1000);
    ans += dp[x][z];
    n -= x;
    if (dp2[x][z] < z && x != 0) {
      n -= (z - dp2[x][z]);
    }
    if (x == 0) {
      n -= z;
      ans += 1;
    }
  }
  cout << ans << '\n';
}
