#include <bits/stdc++.h>
using namespace std;
int dp[2000000], n;
void solve() {
  int i, t;
  dp[0] = 0;
  for (i = 1; i <= n; i++) {
    dp[i] = 1000000000;
    t = i;
    while (t != 0) {
      dp[i] = min(dp[i], dp[i - t % 10] + 1);
      t /= 10;
    }
  }
  cout << dp[n] << endl;
}
int main() {
  cin >> n;
  if (n <= 1000000) solve();
  return 0;
}
