#include <bits/stdc++.h>
using namespace std;
long long N;
long long F[20][10][10] = {{{0}}};
int to[20][10][10] = {{{0}}};
long long Ans[20][10] = {{0}};
void done() {
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      int x = max(i, j);
      if (i == 0 || i < x) {
        F[1][i][j] = 0;
        to[1][i][j] = i;
        continue;
      }
      F[1][i][j] = F[1][i - x][j] + 1;
      to[1][i][j] = to[1][i - x][j];
    }
  }
  for (int l = 2; l <= 18; l++) {
    for (int i = 0; i <= 9; i++)
      for (int j = 0; j <= 9; j++) {
        long long cost = 0;
        int cnt = i;
        for (int x = 9; x >= 1; x--) {
          cost += F[l - 1][cnt][max(x, j)];
          cnt = to[l - 1][cnt][max(x, j)];
          cost++;
          cnt = 10 + cnt - max(max(j, x), cnt);
        }
        cost += F[l - 1][cnt][j];
        cnt = to[l - 1][cnt][j];
        F[l][i][j] = cost;
        to[l][i][j] = cnt;
      }
  }
  long long Ans = 0;
  int Len = 0;
  long long Cnt = N;
  for (; Cnt > 0; Cnt /= 10, Len++)
    ;
  int remains = N % 10;
  N /= 10;
  for (int i = 1; i <= Len - 1; i++) {
    int Need = N % 10;
    N /= 10;
    int Max = 0;
    for (Cnt = N; Cnt > 0; Cnt /= 10) Max = max((long long)Max, Cnt % 10);
    for (; Need >= 0; Need--) {
      Ans += F[i][remains][max(Max, Need)];
      remains = to[i][remains][max(Max, Need)];
      if (Need > 0 || N > 0) {
        Ans++;
        remains = remains + 10 - max(max(Max, Need), remains);
      }
    }
    N--;
  }
  cout << Ans << endl;
  return;
}
int main() {
  cin >> N;
  if (N <= 9)
    cout << (N > 0) << endl;
  else
    done();
  return 0;
}
