#include <bits/stdc++.h>
using namespace std;
int dp[1000006];
int i, N;
void solve(int v) {
  int V = v;
  while (v) {
    dp[V] = min(dp[V], dp[V - (v % 10)] + 1);
    v /= 10;
  }
}
int main() {
  cin >> N;
  for (i = 1; i <= N; i++) dp[i] = 1000000500, solve(i);
  cout << dp[N] << endl;
}
