#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, m, count = 0;
  cin >> t;
  int dp[t + 1];
  while (t != 0) {
    string s = to_string(t);
    int high = 0;
    for (int i = 0; i < s.size(); i++) high = max(high, int(s[i]) - 48);
    t = t - high;
    count++;
  }
  cout << count;
  return 0;
}
