#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  while (n) {
    int temp = n;
    int mx = 0;
    while (temp) {
      if (temp % 10 != 0) {
        mx = max(mx, temp % 10);
      }
      temp /= 10;
    }
    n -= mx;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}
