#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (;;) {
    if (n == 0) {
      cout << ans;
      break;
    }
    int x = n;
    int y = 0;
    while (x) {
      y = max(y, x % 10);
      x /= 10;
      if (y == 9) {
        break;
      }
    }
    n -= y;
    ans++;
  }
  return 0;
}
