#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n;
  cin >> n;
  long int dp[n + 1], t, mn = LONG_MAX, digit;
  dp[0] = 0;
  for (long int i = 1; i <= n; i++) {
    t = i;
    while (t != 0) {
      digit = t % 10;
      if (digit != 0) mn = min(mn, dp[i - digit]);
      t /= 10;
    }
    dp[i] = 1 + mn;
    mn = LONG_MAX;
  }
  cout << dp[n];
}
