When introducing new terms consisting of several words, it is useful to use abbreviations. An abbreviation is a word that consists of the first letters of several consecutive words.
An abbreviation is called
unambiguous if the following two conditions are satisfied:
- It corresponds to exactly one sequence of words in a given text (although this sequence can appear in the text more than once);
- It does not appear in the text by itself.
For example, in the text "
A recursive acronym KINA means "KINA is not abbreviation"", strings "
ARA" and "
K" are unambiguous abbreviations, strings "
A" and "
KINA" are ambiguous abbreviations, and strings "
RAA" and "
KNA" are not abbreviations.
To introduce an abbreviation in a text, it is placed in parentheses right after the sequence of words it corresponds to. Future occurrences of this sequence of words can be replaced by the abbreviation. In the example text above, introduction of the abbreviation "
K" produces the following text: "
A recursive acronym KINA (K) means "K is not abbreviation"".
If two occurrences of a sequence of words overlap, only one of them can be replaced by the abbreviation. Words in a sequence are separated by one or more non-alphabetic characters. Comparison of words is case-insensitive. For example, "
i18n" is an occurrence of the word sequence "
I n".
The effectiveness of an abbreviation is the decrease in the number of letters after introduction of this abbreviation. Only letters are taken into account; spaces, parentheses and all other non-alphabetical characters do not count.
Given a text, find an unambiguous abbreviation with the maximum effectiveness.