#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
int upmin(T1 &x, T2 v) {
  if (x > v) {
    x = v;
    return 1;
  }
  return 0;
}
template <class T1, class T2>
int upmax(T1 &x, T2 v) {
  if (x < v) {
    x = v;
    return 1;
  }
  return 0;
}
const int INF = 0x3f3f3f3f;
int N;
void init() { cin >> N; }
vector<int> dp;
void preprocess() {
  dp = vector<int>(N + 1, INF);
  dp[0] = 0;
}
void dfs(int u) {
  if (dp[u] != INF) {
    return;
  }
  set<int> d;
  for (int v = u; v; v /= 10) {
    if (v % 10 == 0) continue;
    d.emplace(v % 10);
  }
  for (int v : d) {
    dfs(u - v);
    upmin(dp[u], dp[u - v] + 1);
  }
}
void solve() {
  dfs(N);
  cout << dp[N] << endl;
}
signed main() {
  ios::sync_with_stdio(0);
  init();
  preprocess();
  solve();
  return 0;
}
