#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MAXN = (int)1e6 + 10;
const int MOD = 998244353;
pair<ll, int> dp[MAXN][10];
void precalc() {
  for (int n = 10; n < MAXN; n++) {
    string s = to_string(n);
    int big = *max_element(s.begin(), s.end()) - '0';
    for (int d = 0; d < 10; d++) {
      int best = max(big, d);
      dp[n][d].first = 1 + dp[n - best][d].first;
      dp[n][d].second = best + dp[n - best][d].second;
    }
  }
}
ll go(ll n) {
  ll ans = 0;
  if (n == 0) return 0;
  while (n > MAXN) {
    ll high = n;
    int c = 0;
    string s;
    while (s.size() < 6) {
      s += (high % 10) + '0';
      high /= 10;
    }
    reverse(s.begin(), s.end());
    ll low = stoll(s);
    string S = to_string(high);
    ll best = *max_element(S.begin(), S.end()) - '0';
    if (!low) {
      ans++;
      n -= best;
      continue;
    }
    int steps = dp[low][best].first;
    ll nxt = n - dp[low][best].second;
    ll nxt_step = max(nxt % 10, best);
    ans += 1 + steps;
    n = nxt - nxt_step;
  }
  ans += 1 + dp[n][0].first;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  ll n;
  cin >> n;
  precalc();
  cout << go(n) << '\n';
  return 0;
}
