#include <bits/stdc++.h>
using namespace std;
int n, dp[1000005];
int f(int sayi) {
  if (dp[sayi] != -1) return dp[sayi];
  if (sayi == 0) return 0;
  if (sayi < 0) return 100000001;
  int tut = sayi, mn = 100000001;
  while (tut) {
    if ((tut % 10)) {
      mn = min(mn, f(sayi - (tut % 10)));
    }
    tut /= 10;
  }
  return dp[sayi] = mn + 1;
}
int main() {
  cin >> n;
  memset(dp, -1, sizeof dp);
  cout << f(n);
  return 0;
}
