#include <bits/stdc++.h>
using namespace std;
long long dp[21][10][10], n, ans = 0;
int rest[21][10][10], a[21], cnt = 0, s[21];
int main() {
  cin >> n;
  if (n < 10) {
    printf("%d\n", n ? 1 : 0);
    return 0;
  }
  for (int i = 0; i <= 9; i++)
    for (int j = 1; j <= 9; j++) {
      dp[1][i][j] = 1;
      if (j < i) rest[1][i][j] = j - i + 10;
    }
  for (int i = 2; i <= 18; i++)
    for (int j = 0; j <= 9; j++)
      for (int k = 1; k <= 9; k++) {
        int now = k;
        for (int l = 9; l >= 0; l--) {
          int mx = max(l, j);
          dp[i][j][k] += dp[i - 1][mx][now];
          now = rest[i - 1][mx][now];
          if (l && !now) {
            now = 10 - mx;
            dp[i][j][k]++;
          }
        }
        rest[i][j][k] = now;
      }
  bool flag = 0;
  while (n) a[++cnt] = n % 10, n /= 10;
  for (int i = cnt; i; i--) s[i] = max(s[i + 1], a[i]);
  int now = a[1];
  for (int i = 2; i <= cnt; i++) {
    for (int j = a[i]; j >= 0; j--) {
      int mx = max(s[i + 1], j);
      ans += dp[i - 1][mx][now];
      now = rest[i - 1][mx][now];
      if (!now && !(i == cnt && j == 0)) {
        now = 10 - mx;
        ans++;
      }
    }
    a[i + 1]--;
  }
  cout << ans << endl;
  return 0;
}
