#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool smin(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}
template <typename T>
inline bool smax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int N = 2e6 + 10;
int ans[N];
int solve(int n) {
  if (!n) return 0;
  if (ans[n]) return ans[n];
  vector<int> d;
  int x = n;
  while (x) {
    d.push_back(x % 10);
    x /= 10;
  }
  ans[n] = 2e9;
  for (auto u : d)
    if (u) smin(ans[n], solve(n - u) + 1);
  return ans[n];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  cout << solve(n) << '\n';
}
