Letters
A string is a sequence of letters of the alphabet. An increasing character string is a sequence of letters where the next letter (from left to right) never occurs before in the alphabet than the previous letter. For example, ABBD is ascending, while ABBAD is not ascending.
A subsequence of a character string is a character string that can be obtained by removing zero or more characters from the original character string. For example, ANNA is a subsequence of BANANAS. Another example would be ANNS, which is an increasing subsequence string of BANANAS.
Given an string, write a program to determine the size of the largest subsequence of which is an ascending string.
Input
The entry consists of a single line, containing an character string.
Output
Your program must produce a single line, containing a single integer, the size of the largest SS sequence which is a growing string.
Constraints
- The input string contains capital letters of the alphabet, from A to Z.
- length()
Input Samples | Output Samples |
---|---|
BANANAS
|
4
|
AAXBBXZZX
|
7
|
AAA
|
3
|