#include <bits/stdc++.h>
using namespace std;
const int imax = INT32_MAX;
const int imin = INT32_MIN;
const long long int inf = 1e18;
const long long int MOD = 1e9 + 7;
const long long int range = 1e9 + 7;
vector<vector<int>> g;
template <class T>
T cal(T n) {
  return (n * 1ll * (n + 1));
}
template <class T>
T mx(T begin, T end) {
  return max_element(begin, end);
}
template <class T>
T mn(T begin, T end) {
  return min_element(begin, end);
}
template <class T>
void getUnique(vector<T>& nums) {
  sort(nums.begin(), nums.end());
  nums.erase(unique(nums.begin(), nums.end()), nums.end());
}
template <class T>
void print(vector<T> nums) {
  for (T i : nums) cout << i << " ";
  cout << "\n";
}
template <class T>
void read(vector<T>& nums) {
  for (T& i : nums) cin >> i;
}
template <class T>
void alloc(vector<vector<T>*> nums, T n) {
  for (auto nums : nums) nums->resize(n + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int t = 1;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> dp(n + 1, imax);
    dp[0] = 0;
    for (long long int i = 1; i <= n; ++i) {
      long long int num = i;
      while (num > 0) {
        dp[i] = min(dp[i], 1 + dp[i - num % 10]);
        num /= 10;
      }
    }
    cout << dp[n];
  }
  return 0;
}
