#include <bits/stdc++.h>
std::map<std::pair<int, long long>, std::pair<long long, int>> Hash;
std::pair<long long, int> dfs(std::pair<int, long long> p) {
  std::pair<int, long long> ppp = p;
  long long power = 1, x = p.second;
  for (; x >= 10; power *= 10, x /= 10)
    ;
  if (!p.first && !p.second) {
    return {0, 0};
  }
  if (power == 1) {
    if (p.first) {
      if (p.first > p.second) {
        return {1, p.second - p.first};
      } else {
        return {2, -p.first};
      }
    } else {
      return {1, 0};
    }
  }
  if (Hash.count(p)) {
    return Hash[p];
  }
  long long ret = 0;
  while (p.second >= 0) {
    if (!p.first && !p.second) {
      break;
    }
    x = std::max(1ll * p.first, p.second / power);
    std::pair<long long, int> pp = dfs({(int)x, p.second % power});
    p.second = p.second / power * power + pp.second;
    ret += pp.first;
  }
  return Hash[ppp] = {ret, p.second};
}
int main() {
  long long n;
  scanf("%I64d", &n);
  printf("%I64d\n", dfs({0, n}).first);
  return 0;
}
