#include <bits/stdc++.h>
using namespace std;
string alpha = "abcdefghijklmnopqrstuvwxyz";
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
map<pair<long long int, long long int>, pair<long long int, long long int>> dp;
pair<long long int, long long int> dfs(pair<long long int, long long int> x) {
  if (x.second < 10) {
    return (make_pair(x.first || x.second, x.second - max(x.first, x.second)));
  }
  if ((dp.find(x) != dp.end())) {
    return dp[x];
  }
  long long int p = 1;
  while (p <= x.second / 10) {
    p *= 10;
  }
  pair<long long int, long long int> y =
      dfs(make_pair(max(x.first, x.second / p), x.second % p));
  long long int ans = y.first;
  y = dfs(make_pair(x.first, (x.second / p) * p + y.second));
  return dp[x] = make_pair(y.first + ans, y.second);
}
void solve() {
  long long int n;
  cin >> n;
  cout << dfs(make_pair(0, n)).first << endl;
}
