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: Wrong Answer)

#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=500000+10;
char s[maxn];
int a[maxn];
int i,j,k,l,t,n,m,num;
int main(){
	scanf("%s",s);
	n=strlen(s);
	reverse(s,s+n);
	fo(i,0,n-1) a[i]=s[i]-'0';
	t=i=0;
	while (i<n){
		t+=a[i]*9;
		a[i]=t%10;
		t/=10;
		if (t&&i==n-1) n++;
		i++;
	}
	fo(i,0,n-1) num+=a[i];
	fo(k,1,10000000){
		a[0]++;
		num++;
		t=i=0;
		while (i<n){
			t+=a[i];
			num-=a[i];
			a[i]=t%10;
			num+=a[i];
			t/=10;
			if (!t) break;
			if (i==n-1) n++;
			i++;
		}
		if (num==k) break;
	}
	printf("%d\n",(k-1)/9+1);
}