#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  if (n == 0) {
    cout << "0" << endl;
    return 0;
  }
  string s;
  int t, p = 0;
  int m = n;
  for (int i = 0; i < m; i++) {
    t = n;
    stringstream ss;
    ss << t;
    ss >> s;
    sort(s.begin(), s.end());
    int x;
    stringstream xx;
    xx << s[s.size() - 1];
    xx >> x;
    n = n - x;
    p++;
    if (n == 0) {
      break;
    }
  }
  cout << endl << p << endl;
  return 0;
}
