B - Two Colors Card Game Editorial /

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 200

問題文

高橋君は青いカードを N 枚,赤いカードを M 枚持っています。 カードにはそれぞれ文字列が書かれており, i 枚目の青いカードに書かれている文字列は s_ii 枚目の赤いカードに書かれている文字列は t_i です。

高橋君は,文字列を 1 つ言います。 そして,全てのカードを確認し, その文字列が書かれた青いカードを 1 枚見つけるごとに 1 円貰えます。 また,その文字列が書かれた赤いカードを 1 枚見つけるごとに 1 円失います。

なお,高橋君の言った文字列と,カードに書かれた文字列が完全に一致していた場合のみを考えます。 例えば,高橋君が atcoder と言った場合,atcoderratcodebtcoder などと書かれた青いカードがあってもお金は貰えません(逆に,このような文字列が書かれた赤いカードがあってもお金を失うことはありません)。

高橋君は,最大で差し引き何円貰うことができるでしょうか?

ただし,違うカードに同じ文字列が書かれていることもあることに注意してください。

制約

  • N, M は整数
  • 1 \leq N, M \leq 100
  • s_1, s_2, ..., s_N, t_1, t_2, ..., t_M は全て長さ 1 以上 10 以下の文字列で,英小文字のみからなる

入力

入力は以下の形式で標準入力から与えられる。

N
s_1
s_2
:
s_N
M
t_1
t_2
:
t_M

出力

高橋君が最大で差し引き X 円貰える時,X を出力せよ。


入力例 1

3
apple
orange
apple
1
grape

出力例 1

2

apple と言えば,2 円貰うことができます。


入力例 2

3
apple
orange
apple
5
apple
apple
apple
apple
apple

出力例 2

1

apple と言うと,3 円失ってしまいます。orange と言えば,1 円貰うことができます。


入力例 3

1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort

出力例 3

0

voldemort と言うと,9 円失ってしまいます。例えば orange と言えば,1 円も失わずにすみます。


入力例 4

6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue

出力例 4

1

Score : 200 points

Problem Statement

Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.

Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.

Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)

At most how much can he earn on balance?

Note that the same string may be written on multiple cards.

Constraints

  • N and M are integers.
  • 1 \leq N, M \leq 100
  • s_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

N
s_1
s_2
:
s_N
M
t_1
t_2
:
t_M

Output

If Takahashi can earn at most X yen on balance, print X.


Sample Input 1

3
apple
orange
apple
1
grape

Sample Output 1

2

He can earn 2 yen by announcing apple.


Sample Input 2

3
apple
orange
apple
5
apple
apple
apple
apple
apple

Sample Output 2

1

If he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.


Sample Input 3

1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort

Sample Output 3

0

If he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.


Sample Input 4

6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue

Sample Output 4

1