Spelling
Time limit2sMemory limit1024 MB
Given an uppercase string, find the minimum total number of pen lifts needed to write it, using a fixed lift count per letter.
- Level
Easy3 of 10
- Topics
- Implementation
- Solved
- No attempts yet
Statement
Frankenstein likes Marta a lot, but he does not know how to tell her. After thinking it over, he decided to write her a letter confessing his love. His spelling is the problem, though. He is big and clumsy.
Frankenstein composed the letter in his head and sat down to write. He wanted the text to look as neat as possible, so he planned to lift the pen from the paper as few times as he could. Retracing a line is also hard. By 'one place' he means a line of nonzero length. He decided to write each letter separately so he would not get confused. He based the letter shapes on a picture from an English textbook he found:

For example, to write the letter A, Frankenstein has to lift the pen 2 times (he also lifts the pen after finishing the letter). Writing the letter B takes 1 lift.
Input
The first and only line of the input contains the text Frankenstein wants to write. The text consists of uppercase Latin letters and its length does not exceed 1000.
Output
Print a single line with the minimum number of times Frankenstein has to lift the pen from the paper to write the text.