#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
int main() {
  long long int i, n, ans;
  scanf("%lld", &n);
  ans = 0;
  int d = -1;
  while (n != 0) {
    long long int m = n;
    d = -1;
    while (m != 0) {
      int d1 = m % 10;
      m /= 10;
      if (d1 >= d) d = d1;
    }
    n -= d;
    ans++;
  }
  printf("%lld\n", ans);
  return 0;
}
