#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=500005;
int n,ans,a[N];
char s[N];
void gao(int up){
	ans++;
	for(int i=1;i<up;i++){
		if(a[i]<10){
			break;
		}
		a[i+1]+=a[i]/10;
		a[i]%=10;
	}
}
int main(){
	fread(s+1,500000,1,stdin);
	n=strlen(s+1);
	while(s[n]=='\r'||s[n]=='\n'){
		n--;
	}
	for(int i=1;i<=n;i++){
		a[i]=s[n-i+1]-'0';
	}
	for(int i=n,j=n,tot=0;i>1;i--){
		if(a[i]==a[i+1]){
			tot++;
		}else{
			tot=1;
		}
		if(a[i]>a[i-1]){
			if(tot==1){
				a[1]++;
				j=i-1;
				gao(j);
			}else if(i+tot-1==j){
				while(j>=i){
					if(a[i-1]>=a[i]){
						break;
					}
					a[1]++;
					j--;
					gao(j);
				}
				a[j+1]=0;
				i=j+1;
			}else{
				j=i+tot-2;
				a[1]++;
				gao(j);
				a[j+1]=0;
				i=j+1;
			}
		}
	}
	printf("%d\n",ans+1);
	return 0;
}