#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 5;
const double eps = 0;
const long long ms = 0;
const long long md = 0;
long long get(long long n) {
  long long res = 0;
  while (n > 0) {
    res = max(res, n % 10);
    n /= 10;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long ans = 0;
  while (n > 0) {
    n -= get(n);
    ++ans;
  }
  cout << ans;
  return 0;
}
