Given a long string of length and words. Find the number of characters in the string that are overlapped by at least two words that appears in the string. Note that each word might appear more than once in the long string.
and the words will only contain lowercase characters.
Constraints
The sum of the lengths of the words will not exceed .
Input Specification
The first line of input contains a single integer .
The second line of input contains the string .
The third line of input contains a single integer .
The next lines of input each contains a word.
Output Specification
Output the number of characters contained in at least two words.
Sample Input 1
8
aabcdefg
4
aa
abc
def
ef
Sample Output 1
3
Sample Explanation 1
The overlapping characters are shown in blue below.
Sample Input 2
16
fafelmasfelimsdf
5
fa
felim
m
ef
kenneth
Sample Output 2
1
Sample Explanation 2
The only overlapping letter is "m", the overlap from "felim" and "m".
Sample Input 3
3
aaa
1
aa
Sample Output 3
1
Sample Explanation 3
The middle "a" is overlapped by the two "aa".
Comments