Problem:
Score : 1300 points

Problem Statement

We will call a non-negative integer increasing if, for any two adjacent digits in its decimal representation, the digit to the right is greater than or equal to the digit to the left.
For example, 1558, 11, 3 and 0 are all increasing; 10 and 20170312 are not.

Snuke has an integer N. Find the minimum number of increasing integers that can represent N as their sum.

Constraints

1 \leq N \leq 10^{500000}

Input

The input is given from Standard Input in the following format:

N

Output

Print the minimum number of increasing integers that can represent N as their sum.

Sample Input 1

80

Sample Output 1

2

One possible representation is 80 = 77 + 3.

Sample Input 2

123456789

Sample Output 2

1

123456789 in itself is increasing, and thus it can be represented as the sum of one increasing integer.

Sample Input 3

20170312

Sample Output 3

4

Sample Input 4

7204647845201772120166980358816078279571541735614841625060678056933503

Sample Output 4

31

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<cstdio>
#include<cstring>
#define MN 500000
char s[MN+5];
int a[MN+5];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1),l,r,mid,ans,i,x,L,R;
	for(l=1,r=1e6;l<=r;)
	{
		mid=l+r>>1;L=0;R=mid*9;
		for(i=1;i<=n;++i)a[i]=s[i]-'0';
		for(i=n;i;--i)
		{
			R-=((R-a[i])%10+10)%10;
			if(R<L)break;
			x=R/10;R=(R-L)+x;L=x;
		}
		if(i)l=mid+1;else ans=mid,r=mid-1;
	}
	printf("%d",ans);
}