#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1000000000000000000;
const long long int mod = 1E9 + 7;
string subs(string a, char b) {
  for (int i = a.length() - 1; i >= 1; i--) {
    if (a[i] < '0') {
      a[i] = '9';
      a[i - 1] = a[i - 1] - 1;
    }
    if (i != a.length() - 1) continue;
    if (a[i] >= b) {
      a[i] = a[i] - b + '0';
    } else {
      a[i - 1] = a[i - 1] - 1;
      a[i] = ((10 + (a[i] - '0')) - (b - '0')) + '0';
    }
  }
  return a;
}
char bgst(string a) {
  char s = '0';
  for (int i = 0; i < a.length(); i++) {
    if (a[i] > s) s = a[i];
  }
  return s;
}
void solve() {
  string s;
  cin >> s;
  long long int n = s.length();
  string t = "";
  for (int i = 0; i < n; i++) t += '0';
  long long int mvs = 0;
  char subc;
  if (n == 1 && s != "0")
    mvs = 1;
  else if (n == 1 && s == "0")
    mvs = 0;
  else {
    while (s != t) {
      subc = bgst(s);
      s = subs(s, subc);
      mvs += 1;
    }
  }
  cout << mvs << endl;
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  ;
  solve();
}
