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