A string of lowercase letters is called alphabetical if some of the letters can be deleted so that the only letters that remain are the letters from ā€˜aā€™ to ā€˜zā€™ in order. Given a string $s$, determine the minimum number of letters to add anywhere in the string to make it alphabetical.


Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The only line of input contains a string $s$ ($1 \le |s| \le 50$) which contains only lowercase letters.


Output a single integer, which is the smallest number of letters needed to add to $s$ to make it alphabetical.

Sample Input 1 Sample Output 1
Sample Input 2 Sample Output 2
CPU Time limit 1 second
Memory limit 1024 MB
Statistics Show
Source 2016 Southeast USA Regionals Division 1
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in