Problem:
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

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		//StringBuilder s = new StringBuilder();
		String[] s = new String[n];
		int[] countS = new int[n]; //かぶった回数
		for (int i = 0; i < n; i++) {
			String tempS = scan.next();
			if (Arrays.asList(s).contains(tempS)) {
				s[i] = tempS;
				countS[i]++;
			} else {
				s[i] = tempS;
				countS[i]=0;
			}
		}
		//countS[i]内で最大のもののi＝forのi回目で入力したモノ
		int m = scan.nextInt();
		String[] t = new String[m];
		int[] countT = new int[m]; //かぶった回数
		for (int i = 0; i < m; i++) {
			String tempT = scan.next();
			if (Arrays.asList(t).contains(tempT)) {
				t[i] = tempT;
				countT[i]++;
			} else {
				t[i] = tempT;
				countT[i]=0;
			}
		}
		List<String> listS = Arrays.asList(s);
		List<String> listT = Arrays.asList(t);
		//System.out.println(listS);
		//System.out.println(listT);

		int plus[] =new int[n];
		int minus[] = new int[m];
		for(int i=0;i<listS.size();i++) {
			List<String>zanteiS = new ArrayList<>(listS);
			List<String>deleteS = new ArrayList<>();
			deleteS.add(listS.get(i));
			zanteiS.removeAll(deleteS);
			plus[i]=listS.size()-zanteiS.size();
		//	System.out.println(plus[i]);
		}

		for(int i=0;i<listT.size();i++) {
			List<String>zanteiT = new ArrayList<>(listT);
			List<String>deleteT = new ArrayList<>();
			deleteT.add(listT.get(i));
			zanteiT.removeAll(deleteT);
			minus[i]=listT.size()-zanteiT.size();
			//System.out.println(minus[i]);
		}

		int[] count = new int[listS.size()];
		for(int i=0;i<listS.size();i++) {
			count[i] = plus[i];

			for(int l=0;l<listT.size();l++) {
				if(listT.get(l).equals(listS.get(i))) {
					count[i] --;
				}
			}
//System.out.println("count"+count[i]);
		}
int ans =0;
		for(int i=0;i<count.length;i++) {
			ans = Math.max(count[i], ans);
		}
		System.out.println(ans);
		/*
		//plus内の最大値は
		int plusMax =0;
		for(int i=0;i<plus.length;i++) {
			plusMax=Math.max(plusMax, plus[i]);
		}
System.out.println(plusMax);

int minusMin =0;
for(int i=0;i<minus.length;i++) {
	minusMin=Math.min(minusMin, minus[i]);
}
System.out.println(minusMin);

*/

	}

}