#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long cnt = 0;
  while (n) {
    long long num = n;
    long long mx = 0;
    while (num) {
      mx = max(num % 10, mx);
      num /= 10;
    }
    n -= mx;
    cnt++;
  }
  cout << cnt;
}
