#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, pair<long long, long long> > M;
long long n;
pair<long long, long long> dfs(pair<long long, long long> T) {
  if (T.second < 10)
    return make_pair(T.first || T.second, T.second - max(T.first, T.second));
  if (M[T].first) return M[T];
  long long t1, t2;
  pair<long long, long long> t;
  for (t2 = 1; t2 <= T.second / 10; t2 = t2 * 10)
    ;
  t = dfs(make_pair(max(T.first, T.second / t2), T.second % t2)), t1 = t.first;
  t = dfs(make_pair(T.first, T.second / t2 * t2 + t.second));
  return M[T] = make_pair(t1 + t.first, t.second);
}
int main() {
  scanf("%I64d", &n);
  printf("%I64d", dfs(make_pair(0, n)).first);
  return 0;
}
