All problems

Problem 981

Partitioning Into Minimum Number Of Deci-Binary Numbers

Medium · 20 pts · String, Greedy, Math

Problem

A deci-binary number has only the digits 0 and 1 and no leading zeros, like 101 or 1100. Given a positive decimal number N as a string, find the minimum number of positive deci-binary numbers that add up to N. Each deci-binary number adds at most 1 to every digit position, so you need at least as many as the largest digit of N, and that many is always enough. The answer is the largest digit.

Input

A single string N of digits without leading zeros.

Output

Print the minimum number of deci-binary numbers.

Constraints

1 <= |N| <= 100000; N has no leading zeros

Example input

32

Example output

3

Explanation

32 = 10 + 11 + 11, using three deci-binary numbers. The digit 3 needs at least three, so the answer is 3.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Minimum Deletions to Make Array Beautiful Next: Minimum Cost of Buying Candies With Discount