#include <bits/stdc++.h>
using namespace std;
int getlast(long long n) {
  long long m = -1;
  while (n > 0) {
    m = max(m, n % 10);
    n = n / 10;
  }
  return m;
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long cnt = 0;
  while (n > 0) {
    n -= getlast(n);
    cnt++;
  }
  cout << cnt;
}
