WC '18 Contest 2 J3 - Seeing Double

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
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 N (1 \le N \le 100) masks, the i-th of which allows him to impersonate a person whose name is a string A_{i}. Benji agent similarly has M (1 \le M \le 100) masks, the i-th of which allows him to impersonate a person whose name is a string B_{i}. Each of the N + M names is a non-empty string consisting of at most 20 lowercase letters a...z. Neither agent has any duplicate masks in their own set – in other words, the names A_{1\ldots N} are distinct from one another, and the names B_{1\ldots M} 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, N.
N lines follow, the i-th of which consists of a single string, A_{i}, for i = 1\ldots N.
The next line consists of a single integer, M.
M lines follow, the i-th of which consists of a single string, B_{i}, for i = 1\ldots M.

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

There are no comments at the moment.