#include <bits/stdc++.h>
using namespace std;
pair<long long, int> dp[10][10][20][10];
long long n, rk[20];
int i, j, k, l;
void init() {
  for (i = 0; i < 10; i++)
    for (j = 0; j < 10; j++)
      for (k = 0; k < 20; k++)
        for (l = 0; l < 10; l++) {
          dp[i][j][k][l].first = -1;
          dp[i][j][k][l].second = -1;
        }
  rk[0] = 1;
  for (i = 1; i < 19; i++) rk[i] = rk[i - 1] * 10;
}
pair<long long, int> dfs(int a, int b, int c, int d) {
  pair<long long, int> ret, tmp;
  if (dp[a][b][c][d].first != -1) return dp[a][b][c][d];
  if (b == 0) {
    if (d >= a && d > 0) {
      ret.first = 1;
      ret.second = 0;
    } else {
      ret.first = 0;
      ret.second = d;
    }
    dp[a][b][c][d] = ret;
    return ret;
  }
  if (c == 0) {
    if (((a > b) ? a : b) > d)
      tmp = dfs(a, b - 1, c, 10 + d - ((a > b) ? a : b));
    else if (d > 0)
      tmp = dfs(a, b, c, 0);
    else
      tmp = dfs(a, b - 1, c, 10 - ((a > b) ? a : b));
    ret = tmp;
    ret.first++;
    dp[a][b][c][d] = ret;
    return ret;
  }
  if (((a > b) ? a : b) <= d) {
    tmp = dfs(a, b, c, 0);
    ret = tmp;
    ret.first++;
    dp[a][b][c][d] = ret;
    return ret;
  }
  ret.first = 0;
  ret.second = d;
  for (int i = b; i > 0; i--) {
    if (((a > i) ? a : i) > ret.second) {
      ret.first++;
      if (c > 1) ret.first += (rk[c] - 10) / 9;
      tmp = dfs(((a > i - 1) ? a : i - 1), 9, c - 1,
                10 + ret.second - ((a > i) ? a : i));
      ret.first += tmp.first;
      ret.second = tmp.second;
    } else {
      ret.first += 2;
      if (c > 1) ret.first += (rk[c] - 10) / 9;
      tmp = dfs(((a > i - 1) ? a : i - 1), 9, c - 1, 10 - ((a > i) ? a : i));
      ret.first += tmp.first;
      ret.second = tmp.second;
    }
  }
  dp[a][b][c][d] = ret;
  return ret;
}
long long solve(long long n) {
  int a[20], len = 0;
  while (n > 0) {
    a[len++] = (int)(n % 10);
    n /= 10;
  }
  if (len == 1) {
    if (a[0] == 0)
      return 0;
    else
      return 1;
  }
  long long ret = 0;
  pair<long long, int> tmp;
  int _max;
  for (int i = 1; i < len; i++) {
    _max = 0;
    for (int j = i + 1; j < len; j++) _max = ((_max > a[j]) ? _max : a[j]);
    tmp = dfs(_max, a[i], i - 1, a[0]);
    a[i] = 0;
    ret += tmp.first;
    a[0] = tmp.second;
  }
  if (tmp.second > 0) {
    ret++;
  }
  return ret;
}
int main() {
  init();
  cin >> n;
  cout << solve(n) << endl;
  return 0;
}
