#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:666000000")
using namespace std;
const int INF = (1 << 30) - 1;
const long double EPS = 1e-9;
const long double PI = fabs(atan2(0.0, -1.0));
int n;
void load() { cin >> n; }
int sv[1000600];
int rec(const int v) {
  if (-1 != sv[v]) return sv[v];
  bool can[10];
  memset(can, false, sizeof(can));
  {
    int tmp = v;
    while (tmp != 0) {
      can[tmp % 10] = true;
      tmp /= 10;
    }
  }
  int res = INT_MAX;
  for (int i = 1; i <= 9; i++)
    if (can[i]) res = min(res, 1 + rec(v - i));
  return sv[v] = res;
}
void solve() {
  memset(sv, -1, sizeof(sv));
  sv[0] = 0;
  int res = rec(n);
  cout << res;
}
int main() {
  load();
  solve();
  return 0;
}
