#include <bits/stdc++.h>
using namespace std;
long long int maxd(long long int n) {
  long long int temp = 10 * n, mm = 0;
  while (temp /= 10) mm = max(mm, temp % 10);
  return mm;
}
int main() {
  long long int n, ans = 0;
  cin >> n;
  while (n) {
    n -= maxd(n);
    ans++;
  }
  cout << ans;
  return 0;
}
