#include <bits/stdc++.h>
using namespace std;
long long n;
const int maxN = 1000000 + 1;
long long dp[maxN];
int main() {
  cin >> n;
  if (n == 0) {
    cout << "0" << endl;
    return 0;
  }
  if (n <= 9) {
    cout << "1" << endl;
    return 0;
  }
  dp[0] = 0;
  dp[1] = 1;
  dp[2] = 1;
  dp[3] = 1;
  dp[4] = 1;
  dp[5] = 1;
  dp[6] = 1;
  dp[7] = 1;
  dp[8] = 1;
  dp[9] = 1;
  for (int i = 10; i <= n; i++) {
    int t = i;
    dp[i] = 1e16;
    while (t != 0) {
      int d = t % 10;
      dp[i] = min(1ll * dp[i], 1ll * (dp[i - d] + 1));
      t = t / 10;
    }
  }
  cout << dp[n] << endl;
}
