ICPC PACNW 2016 A - Alphabet
View as PDFA string of lowercase letters is called alphabetical if deleting zero or more of its letters can result in the alphabet string abcdefghijklmnopqrstuvwxyz.
Given a string , determine the minimum number of letters to insert anywhere in the string to make it alphabetical.
Input
The input consists of a single line containing the string  
.
It is guaranteed that  consists of lowercase ASCII letters 
a to z only.
Output
Print, on a single line, a single integer indicating the minimum number of letters that must be inserted in order to make the string  alphabetical.
Sample Input 1
xyzabcdefghijklmnopqrstuvw
Sample Output 1
3
Sample Input 2
aiemckgobjfndlhp
Sample Output 2
20
Comments