Woburn Challenge 2018-19 Round 2 - Junior Division
While on an undercover mission in Montreal, agents Ethan Hunt and Benji Dunn of the IMF (Impossible Mission Force) will need to attend an exclusive party to listen in on a terrorist scheme. Of course, they'll both need to disguise themselves as members of the party's guest list to gain entry.
Ethan has a set of () masks, the -th of which
allows him to impersonate a person whose name is a string . Benji
agent similarly has () masks, the -th of which
allows him to impersonate a person whose name is a string . Each
of the names is a non-empty string consisting of at most
lowercase letters a
...z
. Neither agent has any duplicate masks in
their own set – in other words, the names are distinct
from one another, and the names are also distinct from
one another.
Ethan and Benji will each select one of their masks and wear it to the party. However, they'll run into trouble if they happen to both impersonate the same person! Help them determine how many different people exist who might be impersonated by both agents simultaneously.
Input Specification
The first line of input consists of a single integer, .
lines follow, the -th of which consists of a single string,
, for .
The next line consists of a single integer, .
lines follow, the -th of which consists of a single string,
, for .
Output Specification
Output a single integer, the number of different people who might be impersonated by both agents simultaneously.
Sample Input
3
kurt
john
solomon
4
franz
solomon
kurt
james
Sample Output
2
Sample Explanation
It's possible for both Ethan and Benji to impersonate kurt
. It's
also possible for both of them to impersonate solomon
. There are no
other people who might be impersonated by both agents.
Comments