#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 5;
long long c;
long long maxdigit(long long n) {
  long long s = INT_MIN;
  while (n > 0) {
    s = max(s, (n % 10));
    n = n / 10;
  }
  return s;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    c = 0;
    long long n;
    cin >> n;
    while (n > 0) {
      long long k = maxdigit(n);
      c += 1;
      n -= k;
    }
    cout << c;
  }
}
