#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, s1, s2;
  long long a, b, c = 0;
  cin >> s;
  b = stoi(s);
  while (b > 0) {
    s1 = s;
    sort(s1.begin(), s1.end());
    int d = stoi(s1) % 10;
    b = b - d;
    c++;
    s = to_string(b);
  }
  cout << c << "\n";
}
