#include <bits/stdc++.h>
using namespace std;
long long n;
long long dp[1000003][11];
long long dp2[1000003][11];
long long ans;
int main() {
  int temp;
  cin >> n;
  int i, j;
  int maxi;
  for (j = 0; j < 10; j++)
    for (i = 1; i < 1000000; i++) {
      temp = i;
      maxi = j;
      while (temp > 0) {
        maxi = max(maxi, temp % 10);
        temp /= 10;
      }
      if (i - maxi < 0)
        dp[i][j] = 1;
      else
        dp[i][j] = dp[i - maxi][j] + 1;
      if (i < 10)
        dp2[i][j] = maxi;
      else
        dp2[i][j] = dp2[i - maxi][j] + maxi;
    }
  while (n > 0) {
    maxi = 0;
    temp = n / 1000000;
    while (temp > 0) {
      maxi = max(maxi, temp % 10);
      temp /= 10;
    }
    if (n % 1000000 == 0) {
      n -= maxi;
      ans++;
    } else if (n > 0) {
      i = n % 1000000;
      n -= dp2[i][maxi];
      ans += dp[i][maxi];
    }
  }
  cout << ans << endl;
  return 0;
}
