#include <bits/stdc++.h>
using namespace std;
std::vector<long long> digit(long long num) {
  string str, s;
  std::vector<long long> v;
  str = to_string(num);
  for (int i = 0; i < str.size(); ++i) {
    s = str[i];
    v.push_back(stoi(s));
  }
  return v;
}
void solve() {
  long long num, best;
  cin >> num;
  std::vector<long long> arr(num + 11);
  std::vector<long long> d;
  arr[0] = 0;
  for (int i = 1; i < 10; ++i) {
    arr[i] = 1;
  }
  for (int i = 10; i <= num; ++i) {
    best = 2000000000000000000;
    d = digit(i);
    for (auto y : d) {
      if (y != 0) {
        best = min(best, arr[i - y] + 1);
      }
    }
    arr[i] = best;
  }
  cout << arr[num] << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
