#include <bits/stdc++.h>
using namespace std;
long long n, ans, t, b;
int main() {
  cin >> n;
  while (n) {
    ans++, t = n, b = -1;
    while (t) b = max(b, t % 10), t /= 10;
    n -= b;
  }
  cout << ans;
}
