#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5143;
const long long Linf = 1e18 + 5413;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T lcm(T a, T b) {
  return a / __gcd(a, b) * b;
}
inline int read() {
  int res = 0;
  int neg;
  while (true) {
    char ch = getchar();
    if (ch >= '0' && ch <= '9' || ch == '-') {
      if (ch == '-')
        neg = -1;
      else
        neg = 1, res = ch - '0';
      break;
    }
  }
  while (true) {
    char ch = getchar();
    if (ch >= '0' && ch <= '9')
      res *= 10, res += ch - '0';
    else
      break;
  }
  return res * neg;
}
const int MAXN = 1e6 + 5;
int dp[MAXN];
bool contains(int x, int d) {
  while (x) {
    if (x % 10 == d) return true;
    x /= 10;
  }
  return false;
}
int main() {
  int n = read();
  dp[0] = 1;
  for (int(i) = (1); (i) <= (n); (i)++) {
    dp[i] = inf;
    for (int(j) = (0); (j) <= (9); (j)++)
      if (i >= j && contains(i, j)) umin(dp[i], dp[i - j] + 1);
  }
  cout << dp[n] - 1 << endl;
  return 0;
}
