#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, c = 0;
  int x;
  cin >> n;
  map<char, int> m;
  m['0'] = 0, m['1'] = 1, m['2'] = 2, m['3'] = 3, m['4'] = 4, m['5'] = 5,
  m['6'] = 6, m['7'] = 7, m['8'] = 8, m['9'] = 9;
  string a;
  while (n) {
    a = to_string(n);
    string::iterator it = max_element(a.begin(), a.end());
    x = m[*it];
    n = n - x;
    c++;
  }
  cout << c;
  return 0;
}
