ICPC PACNW 2016 A - Alphabet

View as PDF

Submit solution


Points: 7
Time limit: 0.6s
Memory limit: 256M

Problem type

A 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 s, 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 s (1 \le \left|s\right| \le 50).

It is guaranteed that s 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 s alphabetical.

Sample Input 1

xyzabcdefghijklmnopqrstuvw

Sample Output 1

3

Sample Input 2

aiemckgobjfndlhp

Sample Output 2

20
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments

There are no comments at the moment.