#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:20000000")
using namespace std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
long long rll() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
int mas[1000 * 1050];
void solve() {
  int n = ri();
  mas[0] = 0;
  for (int i = (int)(1); i <= (int)(n); i++) {
    int x = i;
    int res = 2e9;
    vector<int> temp;
    while (x) temp.push_back(x % 10), x /= 10;
    for (int j = (int)(0); j <= (int)((int)temp.size() - 1); j++)
      if (temp[j] && i - temp[j] >= 0) res = min(mas[i - temp[j]], res);
    res++;
    mas[i] = res;
  }
  cout << mas[n];
}
int main() {
  solve();
  return 0;
}
