#include <bits/stdc++.h>
using namespace std;
long long int dp[1000005];
long long int helper(long long int n) {
  if (n == 0) return 0;
  if (n < 0) return INT_MAX;
  if (dp[n] != -1) return dp[n];
  long long int ans = INT_MAX;
  long long int N = n;
  while (N > 0) {
    long long int d = N % 10;
    if (d != 0) ans = min(ans, 1 + helper(n - d));
    N /= 10;
  }
  return dp[n] = ans;
}
void solve(long long int T) {
  memset(dp, -1, sizeof dp);
  long long int n;
  cin >> n;
  long long int ans = helper(n);
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int T = 1;
  for (long long int t = 1; t <= T; t++) {
    solve(t);
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
