#include <bits/stdc++.h>
using namespace std;
long long zro = 0;
signed main() {
  long long n;
  cin >> n;
  long long dp[n + 5];
  dp[0] = 0;
  dp[1] = 1;
  for (long long i = 2; i <= n; i++) {
    vector<long long> vv;
    long long g = i;
    while (g > 0) {
      long long h = g % 10;
      g = g / 10;
      vv.push_back(h);
    }
    long long mini = 9999999999;
    for (long long j = 0; j < vv.size(); j++) {
      long long a = vv[j];
      if (a != 0) mini = min(mini, dp[i - a] + 1);
    }
    dp[i] = mini;
  }
  cout << dp[n];
  return 0;
}
