#include <bits/stdc++.h>
using namespace std;
long long n, cnt = 0;
long long MaxDigit(long long x) {
  int maxi = 0, r;
  while (x > 0) {
    r = x % 10;
    maxi = max(maxi, r);
    x /= 10;
  }
  return maxi;
}
void ReadInput() { cin >> n; }
void Solve() {
  while (n > 0) {
    n -= MaxDigit(n);
    cnt++;
  }
  cout << cnt;
}
int main() {
  ReadInput();
  Solve();
}
