#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long c = 0;
  while (n) {
    long long t = n, g = 0;
    while (t) {
      long long rem = t % 10;
      g = max(g, rem);
      t /= 10;
    }
    n -= g;
    c += 1;
  }
  cout << c;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
