#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
int n, f[11111111];
int dfs(int n) {
  if (n == 0) return 0;
  if (f[n]) return f[n];
  int ans = 1000000000, x = n;
  for (; x; x /= 10) {
    if (x % 10 == 0) continue;
    ans = min(ans, dfs(n - x % 10));
  }
  return f[n] = ans + 1;
}
int main() {
  cin >> n;
  cout << dfs(n) << endl;
}
