#P7678. [COCI 2008/2009 #5] LJESNJAK

[COCI 2008/2009 #5] LJESNJAK

Description

Not long ago, when operating systems were not as advanced as they are today, computers could not display some letters in the Croatian alphabet. Therefore, programmers were allowed to replace one such letter with two to three characters that computers could display, as shown in the table below.

Letter that cannot be displayed Replacement characters
č c=
ć c-
dz=
ñ d-
lj
nj
š s=
ž z=

For example, the string ljes=njak can represent six letters in the Croatian alphabet: lj, e, š, nj, a, k.

Now you are given a string. Please find how many letters in the Croatian alphabet the decoded string contains. The matching is greedy: always match the longest possible letter at the current position. For example, lj should not be considered as two English letters l and j.

Besides the special letters listed in the table above, the Croatian alphabet also contains the 26 English letters a to z.

Input Format

The input contains only one line: a string representing an encoded string in the way described above.

Output Format

Output only one line: the number of letters in the Croatian alphabet contained in the decoded string.

dz=ak
3
ljes=njak
6

Hint

Constraints

For all testdata, the length of the string does not exceed 100100, and it contains only lowercase letters and the characters - and =.

Source

This problem is from COCI 2008-2009 CONTEST 5 T1 LJESNJAK. Using the original testdata configuration, the full score is 3030 points.

Translated and organized by Eason_AC.

Translated by ChatGPT 5