#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, mod = 1e9 + 7;
int dp[N];
int solve(long long num) {
  if (num == 0) return 0;
  if (~dp[num]) return dp[num];
  string s = to_string(num);
  int res = mod;
  int x = *max_element(s.begin(), s.end());
  res = min(res, 1 + solve(num - (x - '0')));
  return dp[num] = res;
}
int main() {
  long long n;
  cin >> n;
  memset(dp, -1, sizeof dp);
  printf("%d\n", solve(n));
}
