#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
const long long inf = 0x3f3f3f3f3f3f3f3fll;
map<long long, pair<long long, long long> > dp[11];
pair<long long, long long> dfs(long long n, long long mx) {
  if (n == 0 && mx == 0) return make_pair(0, 0);
  if (n < 10) return make_pair(1ll, (max(n, mx) - n));
  if (dp[mx].count(n)) return dp[mx][n];
  long long t = 1, tn = n;
  while (t * 10.0 <= n) t *= 10;
  pair<long long, long long> ans = make_pair(0, 0);
  while (n > 0) {
    long long k = n / t;
    pair<long long, long long> tmp = dfs(n % t, max(mx, k));
    ans.first += tmp.first;
    n -= n % t + tmp.second;
  }
  ans.second = -n;
  dp[mx].insert(make_pair(tn, ans));
  return ans;
}
int main() {
  long long n;
  cin >> n;
  cout << dfs(n, 0).first << endl;
  return 0;
}
