#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
void solve() {
  int n, ans = 0;
  cin >> n;
  while (n) {
    int m = n, mx = 0;
    while (m) {
      mx = max(mx, m % 10);
      m /= 10;
    }
    n -= mx;
    ans++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int test = 1;
  while (test--) {
    solve();
    cout << '\n';
  }
  return 0;
}
