Module: (Python) Workshop - 7. Lilo and Stitch's rules of life


Problem

3 /5


Stitch is learning English

Problem

Lilo and Nani teach Stitch English words. In addition to memorizing the words themselves, Stitch needs to correctly place stresses in them. Nani has a dictionary that contains all English words with their accents.
Lilo decided to train Stitch to pronounce the words correctly. But since she herself has not yet learned some words, she uses Nani's dictionary for verification. Unfortunately, not all words are present in this dictionary. Lilo decided that in words that are not in the dictionary, she will consider the stress to be correct if it is placed on only one letter.
It turned out that some words can be stressed in more than one way. In this case, the word can be pronounced differently.

Using this dictionary, check Stitch's speech for the correct placement of stress. Determine the number of mistakes Stitch will make.

Input
First enter the number N — number of words in dictionary (\(0 <= N <=20000\)).
Next comes N lines with words from the dictionary. Each word consists of no more than 30 characters. All words consist of small and capital Latin letters. Each word capitalizes exactly one letter — the one that is under stress. The words in the dictionary are in alphabetical order. If there are several possibilities for placing stress in the same word, then these options in the dictionary go in random order.

Next is a recording of Stitch's conversation. A conversation is a line of text with a total volume of no more than 300,000 characters. A string consists of words separated by exactly one space. The length of each word does not exceed 30 characters. All words consist of small and capital Latin letters (capital letters are those letters over which Stitch has put stress). Stitch could mistakenly put more than one stress in a word or not put stress at all.

Imprint 
Print the number of mistakes in Stitch's speech.
 
Examples
# Input Output Note
1
4
cAnnot
cannOt
found
page
thE pAge cAnnot be found
2
In the word cannot, according to the dictionary, there are two options for placing stress. These options in the dictionary can be listed in any order (i.e. cAnnot first, and then cannOt, and vice versa).
Two mistakes made by Stitch are the words be (the emphasis is not placed at all) and fouNd (the emphasis is wrong). The word thE is not in the dictionary, but since Stitch put exactly one stress in it, it is recognized as correct.
2
4
cAnnot
cannOt
found
page
The PAGE cannot be found
4
Incorrectly placed stresses in all words, except for The (it is not in the dictionary, it has exactly one stress). In the rest of the words, either all letters are stressed (in the word PAGE), or not a single stress is set.