#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e6 + 5;
int main() {
  long long int n, temp, maxi;
  cin >> n;
  temp = n;
  int ans = 0;
  while (n) {
    temp = n;
    maxi = 0;
    while (temp) {
      maxi = max(maxi, temp % 10);
      temp /= 10;
    }
    n -= maxi;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
