#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  long long int cnt = 0;
  while (n > 0) {
    long long int k = 0;
    long long int m = n;
    while (m) {
      k = max(k, m % 10);
      m /= 10;
    }
    n -= k;
    cnt++;
  }
  cout << cnt << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
