#include <bits/stdc++.h>
const long long oo = 1e16;
using namespace std;
const int N = 1000005;
long long n, dp[N];
long long num(long long n) {
  if (n == 0) return 0;
  if (dp[n] != -1) return dp[n];
  string s = to_string(n);
  long long res = oo;
  for (int i = 0; i < s.size(); i++)
    if (s[i] != '0') res = min(res, 1 + num(n - (s[i] - '0')));
  return dp[n] = res;
}
int main() {
  cin >> n;
  memset(dp, -1, sizeof(dp));
  cout << num(n);
  return 0;
}
