#include <bits/stdc++.h>
using namespace std;
long long int modulo(long long int a, long long int b) {
  long long int r = a % b;
  return r < 0 ? r + b : r;
}
long long int fac(long long int n) {
  return (n == 1 || n == 0) ? 1 : n * fac(n - 1);
}
void pairsort(int a[], int b[], int n) {
  pair<int, int> v[n];
  for (long long int i = 0; i < n; i++) {
    v[i].first = a[i];
    v[i].second = b[i];
  }
  sort(v, v + n);
  for (long long int i = 0; i < n; i++) {
    a[i] = v[i].first;
    b[i] = v[i].second;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int val = INT_MAX;
  vector<int> a(n + 1, val);
  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (n < 10) {
    cout << 1 << endl;
    return 0;
  }
  for (long long int i = 1; i < 10; i++) {
    a[i] = 1;
  }
  for (long long int i = 10; i < n + 1; i++) {
    int b = min({1, 2, 3, 4});
    a[i] = min({a[i - i % 10], a[i - (i / 10) % 10], a[i - (i / 100) % 10],
                a[i - (i / 1000) % 10], a[i - (i / 10000) % 10],
                a[i - (i / 100000) % 10], a[i - (i / 1000000) % 10]}) +
           1;
  }
  cout << a[n] << endl;
  return 0;
}
