E - Increasing Numbers 解説 /

実行時間制限: 2 sec / メモリ制限: 256 MB

配点 : 1300

問題文

10 進法で表記したとき,桁同士が隣り合っているところではすべて,右にある桁の値のほうが左にある桁の値以上であるような 0 以上の整数を,増加的と呼ぶことにします. たとえば,15581130 は増加的ですが,1020170312 は増加的ではありません.

すぬけ君は,整数 N を持っています. N が最小で何個の増加的な数の和として表されるかを求めてください.

制約

  • 1 \leq N \leq 10^{500000}

入力

入力は以下の形式で標準入力から与えられる。

N

出力

N が最小で何個の増加的な数の和として表されるかを出力せよ.


入力例 1

80

出力例 1

2

例えば,80 = 77 + 3 として表すことができます.


入力例 2

123456789

出力例 2

1

123456789 はそれ自体が増加的なので,1 個の増加的な数の和で表すことができます.


入力例 3

20170312

出力例 3

4

入力例 4

7204647845201772120166980358816078279571541735614841625060678056933503

出力例 4

31

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