#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
const int N = 100000;
pair<long long, int> dp[19][10][10];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  if (n == 0) {
    cout << "0" << '\n';
    return 0;
  }
  if (n < 10) {
    cout << "1\n";
    return 0;
  }
  for (int i = 0; i < 10; i++) {
    for (int a = 0; a < 10; a++) {
      if (i > a) {
        dp[0][i][a].first = 1;
        dp[0][i][a].second = 10 + a - i;
      } else {
        dp[0][i][a].first = 2;
        dp[0][i][a].second = 10 - i;
      }
    }
  }
  for (int d = 1; d < 19; d++) {
    for (int g = 0; g < 10; g++) {
      for (int i = 0; i < 10; i++) {
        long long sum = 0;
        int curr = i;
        for (int j = 9; j >= g; j--) {
          sum += dp[d - 1][j][curr].first;
          curr = dp[d - 1][j][curr].second;
        }
        for (int j = g - 1; j >= 0; j--) {
          sum += dp[d - 1][g][curr].first;
          curr = dp[d - 1][g][curr].second;
        }
        dp[d][g][i].first = sum;
        dp[d][g][i].second = curr;
      }
    }
  }
  long long powers[18];
  powers[0] = 1;
  for (int i = 1; i < 18; i++) {
    powers[i] = powers[i - 1] * 10;
  }
  if (n == powers[17] * 10) {
    cout << dp[17][0][9].first << "\n";
    return 0;
  }
  int arr[19];
  long long temp = n;
  int cnt = 0;
  while (temp > 0) {
    arr[cnt] = temp % 10;
    temp /= 10;
    cnt++;
  }
  int mxs[20];
  mxs[cnt - 1] = arr[cnt - 1];
  for (int i = cnt - 2; i >= 0; i--) {
    mxs[i] = max(mxs[i + 1], arr[i]);
  }
  mxs[cnt] = 0;
  int curr = arr[0];
  long long sum = 0;
  sum += dp[0][mxs[1]][curr].first;
  curr = dp[0][mxs[1]][curr].second;
  for (int i = 1; i < cnt; i++) {
    int j = arr[i] - 1;
    while (j >= 0) {
      sum += dp[i - 1][max(mxs[i + 1], j)][curr].first;
      curr = dp[i - 1][max(mxs[i + 1], j)][curr].second;
      j--;
    }
  }
  cout << sum - 1 << "\n";
}
