#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<long long int> dp(n + 1);
  dp[0] = 0;
  for (long long int i = 1; i <= n; i++) {
    long long int temp = i;
    long long int minSteps = 1e18 + 2;
    while (temp != 0) {
      long long int di = temp % 10;
      temp /= 10;
      if (di == 0) continue;
      minSteps = min(minSteps, 1 + dp[i - di]);
    }
    dp[i] = minSteps;
  }
  cout << dp[n] << endl;
}
