#include <bits/stdc++.h>
using namespace std;
int n;
int dp[1000005];
int main() {
  int i = 0, j = 0, cs = 0, in;
  cin >> n;
  for (i = 0; i <= n; i++) dp[i] = 100000000;
  dp[0] = 0;
  for (i = 1; i <= 9; i++) dp[i] = 1;
  for (i = 10; i <= n; i++) {
    int para = i;
    while (para > 0) {
      int x = para % 10;
      dp[i] = min(dp[i], dp[i - x] + 1);
      para /= 10;
    }
  }
  cout << dp[n] << "\n";
  return 0;
}
