#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000,1000000000")
using namespace std;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-12;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
long long g(long long n) {
  long long Max = 0;
  while (n) {
    Max = max(Max, n % 10);
    n /= 10;
  }
  return Max;
}
long long f(long long n) {
  long long res = 0;
  while (n) n -= g(n), res++;
  return res;
}
int main(void) {
  long long n;
  cin >> n;
  cout << f(n) << endl;
  return 0;
}
