[BOJ 13741] Alphabet

View as PDF

Submit solution

Points: 2
Time limit: 2.0s
Memory limit: 512M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

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' toz' in order.</p>

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 ≤ |s| ≤ 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.

예제 입력 1

xyzabcdefghijklmnopqrstuvw

예제 출력 1

3

예제 입력 2

aiemckgobjfndlhp

예제 출력 2

20

Comments

There are no comments at the moment.