and are under suspicion of plagiarism, a serious crime at William Lyon Mackenzie CI. They were supposed to complete a project involving writing French words on a piece of paper in alphabetical order and presenting their definitions to the class. To see if they truly plagiarized, you are to write a program to determine how many unique words they share in common.
Input Specification
The first line contains two integers, and (), the number of words in 's and 's respective projects.
The second line contains strings, the words in the first list.
The third line contains strings, the words in the second list.
It is guaranteed that each string consists only of characters a
-z
and has length at most .
Output Specification
Output the number of unique words they share in common.
Sample Input
4 4
a b c d
b c z zz
Sample Output
2
Comments
Hint: words are not distinct and should only count them once
To clarify, the question is essentially asking to count the number of distinct words that occur at least once on both lines.
Clarification
Assuming words in each essay aren't distinct, what would output be in this case:
5 5
aa bb bb cc ee
aa bb ff gg hh
I'm guessing 2? Not sure :v