#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
vector<int> g[200001];
bool vis[200001] = {0};
bool sortinrev(const pair<string, long long> &a,
               const pair<string, long long> &b) {
  return (a.first.size() < b.first.size());
}
vector<pair<int, int> > v;
int fun(long long a, long long b) {
  if (a == b) return 0;
  if (a > b) {
    if ((a - b) % 2 == 0)
      return 1;
    else
      return 2;
  }
  if (a < b) {
    if ((b - a) % 2 == 1)
      return 1;
    else
      return 2;
  }
}
long long modd = 998244353;
int n;
int cnt(int n) {
  int c = 0;
  while (n > 0) {
    c = max(c, n % 10);
    n /= 10;
  }
  return c;
}
int32_t main() {
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  if (n == 0) {
    cout << 0;
    return 0;
  }
  vector<int> v;
  v.push_back(n - cnt(n));
  int i = 0;
  while (1) {
    if (v[i] == 0) break;
    v.push_back(v[i] - cnt(v[i]));
    i++;
  }
  cout << v.size();
  return 0;
}
