#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 5;
long long ans = 1e18;
map<long long, bool> mp;
void solve(long long n, long long cnt) {
  if (!n) {
    cout << cnt;
    exit(0);
  }
  string s = to_string(n);
  sort(s.rbegin(), s.rend());
  solve(n - (s[0] - '0'), cnt + 1);
}
inline long long solve() {
  long long n;
  cin >> n;
  solve(n, 0);
  cout << ans;
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  solve();
  return 0;
}
