String Rank
문제
Let and be strings consisting of the English lowercase alphabet. We say that a string is a subsequence of a string if there exists a strictly increasing sequence of integers , where , and for all . Here, denotes the -th character of the string . Let denote the suffix . If , then is the empty string denoted by .
Given a nonempty string and a positive integer , we define the -set of to be the set of subsequences of whose lengths are . This implies that, for any string , the empty string belongs to by definition.
For example, when aaba, we have aaba, a, b, ba, ab, aa, aba, aab, aaa.
For a string , we define the rank of to be the minimum integer such that the -sets for all suffixes of are all different. In other words, the rank of is \min\{t ≥ 1 | Q_t(w[i:]) \ne Q_t(w[j:]), ∀1 ≤ i < j ≤ 𝑛\}.
For instance, when aaba, the -sets aba and aaba are equal. On the other hand, for , we have
- ,
a,a,ba,a,b,ba,aba,a,b,ba,ab,aa,aba,aaba,a,b,ba,ab,aa,aba,aab,aaa.
Therefore, the rank of the string aaba is .
Given a string , write a program to output its rank.
입력
Your program is to read from standard input. The input consists of a single nonempty string , which consists only of lowercase characters from the English alphabet. The length of the string is at most .
출력
Your program is to write to standard output. Print exactly one line. The line should contain a positive integer to represent the rank of the input string .
예제
예제 1
aabbb
3
예제 2
abacb
2
예제 3
azadzzadaz
4
예제 4
a
1