#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  int c = 0;
  while (n > 0) {
    stringstream s;
    s << n;
    string s1;
    s >> s1;
    sort(s1.begin(), s1.end());
    int a = s1[s1.size() - 1] - '0';
    n = n - a;
    c++;
  }
  cout << c;
}
