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