#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
map<int, int> dp;
int solve(int num) {
  if (num == 0) {
    return 0;
  }
  if (dp[num]) {
    return dp[num];
  }
  vector<int> v;
  int temp = num;
  while (temp) {
    v.push_back(temp % 10);
    temp /= 10;
  }
  int ret = -OO;
  for (int i = 0; i < v.size(); ++i) {
    ret = max(ret, v[i]);
  }
  return dp[num] = 1 + solve(num - ret);
}
int main() {
  dp.clear();
  int num;
  cin >> num;
  cout << solve(num);
  return 0;
}
