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 Ruby (2.3.3) (judge verdict: Wrong Answer)

def previous_inclemently_number(n)
    len = Math.log10(n).to_i
    retv = 0
    begin
        a, b = take_digit(n, len), take_digit(n, len-1)
        retv = retv*10+a
        break if a>b
        len-=1
    end while len>=0
    return retv if len == 0
    return retv * (10**len)-1
end
def take_digit(n,l)
    n/(10**l)%10
end
def test
    def test_(n, cnt)
        return cnt if n == 0
        return test_(n-previous_inclemently_number(n), cnt+1)
    end
    while line=gets
        break if line.chomp == ""
        puts test_(line.to_i, 0)
    end
end
test