Croatian Alphabet
InterviewTime limit1sMemory limit128 MB
Parse a string left to right, greedily matching multi-character Croatian letter codes (like c=, dz=, lj), and count total letters.
- Level
Easy3 of 10
- Topics
- String, Greedy, Implementation
- Solved
- No attempts yet
Problem
Some older operating systems could not type Croatian letters directly, so the letters were entered using the strings in the table below.
Given a word, output how many Croatian alphabet letters it contains.
dz= is always counted as one letter and must not be split into d and z=. Likewise, lj and nj are always counted as one letter. Any character sequence not listed in the table is counted one character at a time.
Input
The first line contains a word of at most 100 characters.
The word consists only of lowercase English letters, -, and =. Croatian letters listed in the table are given in their corresponding input form.
Output
Output the number of Croatian alphabet letters in the given word.