#include <bits/stdc++.h>
using namespace std;
long long dp[10][(int)(1e6) + 1], son[10][(int)(1e6) + 1], ans, mx, x, n;
int f(int x) {
  int mx = 0;
  while (x) {
    mx = max(mx, x % 10);
    x /= 10;
  }
  return mx;
}
int main() {
  for (int j = 0; j <= 9; j++) {
    dp[j][0] = 0;
    for (int i = 1; i <= 1000000; i++) {
      dp[j][i] = 1000000007;
      mx = max(f(i), j);
      if (mx > i) {
        mx = i;
        dp[j][i] = 1;
        son[j][i] = i;
      } else {
        dp[j][i] = dp[j][i - mx] + 1;
        son[j][i] = son[j][i - mx];
      }
    }
  }
  cin >> n;
  x = n % (int)(1e6);
  for (int i = n / (int)(1e6); i >= 0; i--) {
    mx = f(i);
    ans += dp[mx][x];
    if (!son[mx][x] && i) {
      ans++;
      x = (int)(1e6) - mx;
    } else
      x = (int)(1e6) + son[mx][x] - mx;
  }
  cout << ans << '\n';
}
