#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 7;
int n;
int dp[MAX];
int main() {
  cin >> n;
  for (int i = 1; i < MAX; i++) {
    int minn = MAX, t = i;
    while (t) {
      if (t % 10) minn = min(minn, dp[i - t % 10] + 1);
      t /= 10;
    }
    dp[i] = minn;
  }
  cout << dp[n];
}
