#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000 + 10, inf = 1e9;
int dp[MAX];
int main() {
  long long n;
  cin >> n;
  dp[1] = 1;
  dp[2] = 1;
  dp[3] = 1;
  dp[4] = 1;
  dp[5] = 1;
  dp[6] = 1;
  dp[7] = 1;
  dp[8] = 1;
  dp[9] = 1;
  dp[0] = 0;
  for (int i = 10; i <= n; i++) {
    dp[i] = inf;
    vector<int> v;
    int t = i;
    while (t > 0) {
      v.push_back(t % 10);
      t /= 10;
    }
    for (int j = 0; j < v.size(); j++) dp[i] = min(dp[i], dp[i - v[j]]);
    dp[i]++;
  }
  cout << dp[n];
  return 0;
}
