#include <cstdio>
#include <cstring>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter_r(i, n) for (int i = n; i >= 1; --i)

#define NR 501000

int a[NR], n, p[NR];
char s[NR];

void inc() {
	++a[n];
	iter_r(i, n) {
	//	printf("!!%d %d\n", i, a[i]);
		if (a[i] >= 10) {
			a[i] -= 10;
			++a[i - 1];
		} else {
			for (int j = i; j <= n; ++j)
				p[j] = (a[j] == a[j - 1] ? p[j - 1] : j);
			break;
		}
	}
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	a[0] = -1;
	iter(i, n) {
		a[i] = s[i] - '0';
		p[i] = (a[i] == a[i - 1] ? p[i - 1] : i);
	}

	int lst = 0, ans = 0;
	iter(i, n) {
		if (a[i] > a[i + 1] || i == n) {
			//printf("!%d %d %d %d\n", i, a[i], a[i-1], ans);
			if (p[i] != i) {
				for (int j = p[i]; j <= i; ++j) {
					for (; i < n && a[i] <= a[i + 1]; ++i)
						;
					bool exit = false;
					if (a[j] != a[i] || i == n) exit = true; 
					inc(); ++ans;
					if (exit) break;

				}
			} else {
				inc(); ++ans; 
			}
			
		}
	}

	printf("%d\n", ans);

	return 0;
}
