Identifier Sequence

시간 제한7초메모리 제한128 MB

요약
앞의 0을 허용하면서 같은 수를 나타내는 조각이 겹치지 않도록 숫자열을 최대한 많은 조각으로 자르는 문제입니다.
난이도

보통10점 중 6점

유형
동적 계획법, 해시맵, 문자열
정답자
아직 제출이 없습니다

문제

Johnny is a hacker and recently he came into possession of a database of a large bank. The most important task at hand is to extract the clients' IDs from it. They are sorted and concatenated into a single sequence of digits, without the marks where the concatenation took place; these marks are in a separate file, which Johnny does not have. Johnny wants to retrieve the IDs, that is, compute how many IDs can be obtained by cutting the sequence into pieces. Johnny believes in his luck: if the there are many ways to cut the sequence, surely the one that maximises the number of IDs is the correct one.

As the clients' IDs were assigned at different stages, they can be of different lengths and can have leading zeroes. But Johnny knows that each ID has a unique numerical value, when treated as number written in base-10 positional notation.

입력

First and only line of the input contains a sequence on nn (1≤n≤1061 \leq n \leq 10^6) base-10 digits. There are no other characters between those digits, in particular, no spaces. This is the sequence of IDs, which Johnny has.

출력

You should write one natural number --- the maximal number of clients' IDs into which the sequence can be cut.

힌트

The sequence of clients' IDs corresponding to the answer is : 11, 0505, 4040, 910910. Note the ID 0505 has a numerical value 55.

예제1

  1. 예제 1

    입력
    10540910
    
    예상 출력
    4