AtCoder Beginner Contest 091 - Two Colors Card Game

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-----
3
apple
orange
apple
1
grape

-----Sample Output-----
2

He can earn 2 yen by announcing apple.

Difficulty: EASY

Starter code:

Solutions:
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
l = list(set(s))
for i in range(len(l)):
	ans = max(ans, s.count(l[i]) - t.count(l[i]))
print(ans)


n = int(input())
a = {}
for i in range(n):
	s = str(input())
	if s in a.keys():
		a[s] = a[s] + 1
	else:
		a[s] = 1
m = int(input())
for i in range(m):
	t = str(input())
	if t in a.keys():
		a[t] = a[t] - 1
	else:
		a[t] = -1
if max(a.values()) >= 0:
	print(max(a.values()))
elif max(a.values()) < 0:
	print(0)


def main():
	N = int(input())
	s = [input() for _ in range(N)]
	M = int(input())
	t = [input() for _ in range(M)]
	y = 0
	for ss in set(s):
		yy = s.count(ss) - t.count(ss)
		if y < yy:
			y = yy
	print(y)
main()


from collections import Counter

def main():
	n = int(input())
	blue = Counter((input() for _ in range(n)))
	m = int(input())
	red = Counter((input() for _ in range(m)))
	ans = 0
	for (name, amount) in blue.items():
		if name in red.keys():
			temp = amount - red[name]
		else:
			temp = amount
		ans = max(ans, temp)
	print(ans)
main()


from collections import Counter
N = int(input())
S = Counter([input() for _ in range(N)])
M = int(input())
T = Counter([input() for _ in range(M)])
ans = 0
for (word, count) in S.items():
	temp = count - T[word]
	ans = max(ans, temp)
print(ans)


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
a = 0
for i in set(s):
	a = max(s.count(i) - t.count(i), a)
print(a)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	word_dict = {}
	for i in range(n):
		s = input().rstrip()
		if s not in word_dict:
			word_dict[s] = 1
		else:
			word_dict[s] += 1
	m = int(input())
	for j in range(m):
		t = input().rstrip()
		if t in word_dict:
			word_dict[t] -= 1
		else:
			word_dict[t] = -1
	if max(word_dict.values()) < 0:
		print(0)
	else:
		print(max(word_dict.values()))

def __starting_point():
	main()
__starting_point()


n = int(input())
s = [input().split() for i in range(n)]
m = int(input())
t = [input().split() for i in range(m)]
ans = 0
for i in range(n):
	temp = s.count(s[i]) - t.count(s[i])
	ans = max(ans, temp)
print(ans)


n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
tt = [input() for _ in range(m)]
ans = 0
for s in ss:
	ans = max(ans, ss.count(s) - tt.count(s))
print(ans)


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0
for c in s:
	ans = max(s.count(c) - t.count(c), ans)
print(ans)


n = int(input())
S = [input() for i in range(n)]
m = int(input())
T = [input() for i in range(m)]
ans = 0
for s in set(S):
	ans = max(ans, S.count(s) - T.count(s))
print(ans)


N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
Get = {}
for s in S:
	if s in Get:
		Get[s] += 1
	else:
		Get[s] = 1
for t in T:
	if t in Get:
		Get[t] += -1
	else:
		Get[t] = -1
ans = max(Get.values())
print(ans if ans > 0 else 0)


N = int(input())
s = [str(input()) for i in range(N)]
M = int(input())
t = [str(input()) for i in range(M)]
ans = 0
for i in s:
	ans = max(ans, s.count(i) - t.count(i))
print(ans)


N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
Pt = max([S.count(s) - T.count(s) for s in S])
print(max(0, Pt))


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
res = 0
for i in set(s):
	res = max(s.count(i) - t.count(i), res)
print(res)


n = int(input())
d = {'': 0}
for _ in range(n):
	s = input()
	d[s] = d.get(s, 0) + 1
m = int(input())
for _ in range(m):
	t = input()
	d[t] = d.get(t, 0) - 1
print(max(d.values()))


s = [input() for i in range(int(input()))]
t = [input() for i in range(int(input()))]
l = list(set(s))
print(max(0, max((s.count(l[i]) - t.count(l[i]) for i in range(len(l))))))


N = int(input())
S = [str(input()) for i in range(N)]
M = int(input())
T = [str(input()) for i in range(M)]
ans = 0
for i in range(N):
	ans = max(ans, S.count(S[i]) - T.count(S[i]))
print(ans)


from collections import *
(a, b) = eval('Counter([input()for _ in[0]*int(input())]),' * 2)
print(max([0] + [v for v in (a - b).values()]))


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
result = 0
for i in range(n):
	result = max(result, s.count(s[i]) - t.count(s[i]))
print(result)


s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
U = set(s)
ans = 0
for u in U:
	ans = max(ans, s.count(u) - t.count(u))
print(ans)


(n, *s) = open(0)
print(max(0, *[s.count(i) - s[int(n):].count(i) * 2 for i in s]))


n = int(input())
str_dict = dict()
for i in range(n):
	s = input()
	if s not in str_dict:
		str_dict[s] = 1
	else:
		str_dict[s] += 1
m = int(input())
for i in range(m):
	t = input()
	if t not in str_dict:
		str_dict[t] = -1
	else:
		str_dict[t] -= 1
res = max(0, sorted(list(str_dict.values()))[-1])
print(res)


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
print(max([s.count(S) - t.count(S) for S in s] + [0]))


s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
y = [s.count(c) - t.count(c) for c in set(s)]
print(max(0, max(y)))


from collections import *
(n, *a) = open(0).read().split()
print(max(0, max((v - Counter(a[int(n) + 1:])[k] for (k, v) in Counter(a[0:int(n)]).items()))))


n = int(input())
s = list((input() for i in range(n)))
m = int(input())
t = list((input() for i in range(m)))
r = list(set(s + t))
ans = 0
for i in r:
	a = s.count(i)
	b = t.count(i)
	ans = max(ans, a - b)
print(ans)


words = {'': 0}
N = int(input())
for i in range(N):
	word = input()
	words[word] = words.get(word, 0) + 1
M = int(input())
for i in range(M):
	word = input()
	words[word] = words.get(word, 0) - 1
print(max(words.values()))


n = int(input())
ln = [input() for i in range(n)]
m = int(input())
lm = [input() for i in range(m)]
ans = 0
for s in set(ln):
	ans = max(ans, ln.count(s) - lm.count(s))
print(ans)


s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
a = list(set(s))
print(max(0, max((s.count(a[i]) - t.count(a[i]) for i in range(len(a))))))


n = int(input())
s = []
t = []
for i in range(n):
	s.append(input())
m = int(input())
for i in range(m):
	t.append(input())
m = 0
for i in range(n):
	x = s.count(s[i]) - t.count(s[i])
	m = max(m, x)
print(m)


b = []
r = []
c = []
n = int(input())
cnt = 0
for i in range(n):
	s = input()
	b.append(s)
m = int(input())
for j in range(m):
	t = input()
	r.append(t)
for i in b:
	cnt += b.count(i) - r.count(i)
	c.append(cnt)
	cnt = 0
print(max(max(c), 0))


from collections import defaultdict
d = defaultdict(int)
for _ in range(int(input())):
	d[input()] += 1
for _ in range(int(input())):
	d[input()] -= 1
print(max(0, max(d.values())))


a = int(input())
b = list((input() for i in range(a)))
c = int(input())
d = list((input() for i in range(c)))
e = [0]
for s in b:
	e.append(b.count(s) - d.count(s))
else:
	print(max(e))


n = int(input())
sn = [input() for _ in range(n)]
m = int(input())
sm = [input() for _ in range(m)]
l = list(set(sn))
print(max(0, max([sn.count(l[i]) - sm.count(l[i]) for i in range(len(l))])))


from collections import Counter as c
(n, *s) = open(0)
n = int(n)
print(max([0] + [v for v in (c(s[:n]) - c(s[n + 1:])).values()]))


N = int(input())
S = [input() for n in range(N)]
M = int(input())
T = [input() for m in range(M)]
ans = 0
for s in S:
	ans = max(ans, S.count(s) - T.count(s))
print(ans)


import collections
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
maxi = 0
for i in range(len(S)):
	if S.count(S[i]) - T.count(S[i]) > maxi:
		maxi = S.count(S[i]) - T.count(S[i])
print(maxi)


n = int(input())
N = [input() for i in range(n)]
m = int(input())
M = [input() for i in range(m)]
l = list(set(N))
print(max(0, max((N.count(l[i]) - M.count(l[i]) for i in range(len(l))))))


s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
print(max(0, max([s.count(i) - t.count(i) for i in set(s)])))


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ss = set(s)
ans = [0]
for i in ss:
	ans.append(s.count(i) - t.count(i))
print(max(ans))


N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for j in range(M)]
o = 0
for k in s:
	ans = max(s.count(k) - t.count(k), o)
	o = ans
print(ans)


N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
A = [0]
for j in s:
	A.append(s.count(j) - t.count(j))
print(max(A))


n = int(input())
a = []
for i in range(n):
	a.append([input(), 0])
m = int(input())
b = []
for i in range(m):
	b.append([input(), 0])
res = 0
for i in range(n):
	c = 0
	if a[i][1] == 0:
		a[i][1] = 1
		for j in range(i, n):
			if a[i][0] == a[j][0]:
				c += 1
				a[j][1] = 1
		for j in range(m):
			if a[i][0] == b[j][0]:
				c -= 1
	res = max(res, c)
print(res)


n = int(input())
sl = list((input() for _ in range(n)))
m = int(input())
tl = list((input() for _ in range(m)))
sls = set(sl)
m = 0
for s in sls:
	m = max(m, sl.count(s) - tl.count(s))
print(m)


n = int(input())
sl = list((input() for _ in range(n)))
m = int(input())
tl = list((input() for _ in range(m)))
cnt = 0
for s in sl:
	cnt = max(cnt, sl.count(s) - tl.count(s))
print(cnt)


N = int(input())
S = [input() for n in range(N)]
M = int(input())
T = [input() for m in range(M)]
A = [0]
for s in S:
	A.append(S.count(s) - T.count(s))
print(max(A))


b = [input() for i in range(int(input()))]
r = [input() for i in range(int(input()))]
o = 0
for w in list(set(b)):
	o = max(o, b.count(w) - r.count(w))
print(o)


n = int(input())
blue = [input() for _ in range(n)]
bset = set(blue)
m = int(input())
red = [input() for _ in range(m)]
print(max([max(0, blue.count(b) - red.count(b)) for b in bset]))


n = int(input())
S = [input() for _ in range(n)]
m = int(input())
T = [input() for _ in range(m)]
ans = 0
for s in S:
	ans = max(ans, S.count(s) - T.count(s))
print(ans)


N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
list = [s.count(i) - t.count(i) for i in set(s)]
print(max(0, *list))


n = int(input())
s = []
for i in range(n):
	s.append(input())
m = int(input())
t = []
for i in range(m):
	t.append(input())
words = set(s + t)
max_val = 0
for word in words:
	ans = s.count(word)
	ans -= t.count(word)
	if ans > max_val:
		max_val = ans
print(max_val)


N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

def ans091(N: int, s: list, M: int, t: list):
	test_count = 0
	own = list(set(s))
	for i in range(len(own)):
		if test_count <= s.count(own[i]) - t.count(own[i]):
			test_count = s.count(own[i]) - t.count(own[i])
	if test_count > 0:
		return test_count
	else:
		return 0
print(ans091(N, s, M, t))


N = int(input())
n = [str(input()) for i in range(N)]
M = int(input())
m = [str(input()) for i in range(M)]
print(max(0, max((n.count(n[i]) - m.count(n[i]) for i in range(N)))))


N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
print(max(0, max([s.count(a) - t.count(a) for a in s])))


N = int(input())
Blue = [input() for i in range(N)]
M = int(input())
Red = [input() for i in range(M)]
L = [0]
for b in set(Blue):
	L.append(Blue.count(b) - Red.count(b))
print(max(L))


N = int(input())
ss = [input() for i in range(N)]
M = int(input())
ts = [input() for i in range(M)]
ssset = set(ss)
cnt = 0
for x in ssset:
	cnt = max(cnt, ss.count(x) - ts.count(x))
print(cnt)


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
for ele in s:
	ans = max(ans, s.count(ele) - t.count(ele))
print(ans)


from collections import Counter
c = Counter([input() for i in range(int(input()))])
c -= Counter([input() for i in range(int(input()))])
print(c.most_common()[0][1] if c else 0)


s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
cnt = [0] * (len(s) + 1)
for i in range(len(s)):
	cnt[i] = s.count(s[i]) - t.count(s[i])
print(max(cnt))


(n, *s) = open(0).readlines()
n = int(n)
print(max(0, *[s[:n].count(i) - s[n:].count(i) for i in s[:n]]))


s = list((input() for _ in range(int(input()))))
t = list((input() for _ in range(int(input()))))
print(max(0, max((s.count(S) - t.count(S) for S in set(s)))))


N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
s_dic = {}
t_dic = {}
for i in s:
	if i in s_dic.keys():
		s_dic[i] += 1
	else:
		s_dic[i] = 1
for i in t:
	if i in t_dic.keys():
		t_dic[i] += 1
	else:
		t_dic[i] = 1
all_list = []
for i in s_dic.keys():
	if i in t_dic.keys():
		all_list.append(s_dic[i] - t_dic[i])
	else:
		all_list.append(s_dic[i])
for i in t_dic.keys():
	if i in s_dic.keys():
		all_list.append(s_dic[i] - t_dic[i])
	else:
		all_list.append(-t_dic[i])
print(max(max(all_list), 0))


N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
st_dict = {}
for i in range(N):
	if s[i] not in st_dict.keys():
		st_dict[s[i]] = 1
	else:
		st_dict[s[i]] += 1
for i in range(M):
	if t[i] not in st_dict.keys():
		st_dict[t[i]] = -1
	else:
		st_dict[t[i]] -= 1
if max(st_dict.values()) < 0:
	print(0)
else:
	print(max(st_dict.values()))


a = int(input())
b = [input() for i in range(a)]
x = int(input())
y = [input() for i in range(x)]
list = [b.count(i) - y.count(i) for i in set(b)]
print(max(0, *list))


from collections import Counter
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
S = Counter(s)
T = Counter(t)
for (key, value) in list(S.items()):
	if key in list(T.keys()):
		S[key] -= T[key]
if max(S.values()) > 0:
	print(max(S.values()))
else:
	print(0)


N = int(input())
s = []
for i in range(N):
	s.append(input())
M = int(input())
t = []
for i in range(M):
	t.append(input())

def point(x):
	result = 0
	result += s.count(x)
	result -= t.count(x)
	return result
ans = 0
for word in set(s):
	if ans < point(word):
		ans = point(word)
print(ans)


n = int(input())
blues = [input() for _ in range(n)]
m = int(input())
reds = [input() for _ in range(m)]
max_price = 0
for blue in blues:
	plus = len(list([x for x in blues if x == blue]))
	minus = len(list([x for x in reds if x == blue]))
	price = plus - minus
	if price > max_price:
		max_price = price
print(max_price)


from collections import *
C = Counter
n = int(input())
c = C((input() for _ in range(n)))
m = int(input())
c.subtract(C((input() for _ in range(m))))
print(max(max(c.values()), 0))


N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
ans = 0
P = set(S)
for i in P:
	ans = max(ans, S.count(i) - T.count(i))
print(ans)


N = int(input())
S = [input() for _ in range(N)]
S_set = set(S)
M = int(input())
T = [input() for _ in range(M)]
m = 0
for s in S_set:
	m = max(m, S.count(s) - T.count(s))
print(m)


def main():
	blue = [input() for i in range(int(input()))]
	red = [input() for i in range(int(input()))]
	l = list(set(blue))
	print(max(0, max((blue.count(l[i]) - red.count(l[i]) for i in range(len(l))))))

def __starting_point():
	main()
__starting_point()


N = int(input())
s = {}
for i in range(N):
	x = input()
	if x in s:
		s[x] += 1
	else:
		s[x] = 1
M = int(input())
t = {}
for i in range(M):
	x = input()
	if x in t:
		t[x] += 1
	else:
		t[x] = 1
b = list(s.keys())
r = list(t.keys())
subs = []
for i in range(len(b)):
	if b[i] in r:
		subs.append(s[b[i]] - t[b[i]])
	else:
		subs.append(s[b[i]])
print(max(0, max(subs)))


from collections import Counter
n = int(input())
s = [None] * n
for i in range(n):
	s[i] = input().rstrip()
m = int(input())
t = [None] * m
for i in range(m):
	t[i] = input().rstrip()
ctr = Counter(s) - Counter(t)
if ctr:
	print(ctr.most_common(1)[0][1])
else:
	print(0)


n = int(input())
s = []
for i in range(n):
	s.append(input())
from collections import Counter
cs = Counter(s)
m = int(input())
for i in range(m):
	t = input()
	if cs[t]:
		cs[t] -= 1
print(cs.most_common(1)[0][1], flush=True)


s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
c = [0]
for i in s:
	c.append(s.count(i) - t.count(i))
print(max(c))


N = int(input())
As = [input() for _ in range(N)]
M = int(input())
Bs = [input() for _ in range(M)]
c = max([As.count(a) - Bs.count(a) for a in As])
print(0 if c < 0 else c)


n = int(input())
blue = list()
for i in range(n):
	blue.append(input())
m = int(input())
red = list()
for j in range(m):
	red.append(input())
ans = 0
for p in range(n):
	cnt = 0
	for q in range(n):
		if blue[p] == blue[q]:
			cnt += 1
	for r in range(m):
		if blue[p] == red[r]:
			cnt -= 1
	ans = max(ans, cnt)
print(ans)


N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
print(max([s.count(S) - t.count(S) for S in s] + [0]))


l = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
n = set(l)
h = max([l.count(i) - m.count(i) for i in n])
print(max(0, h))


N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
ans = max(max((S.count(x) - T.count(x) for x in set(S))), 0)
print(ans)


n = int(input())
s = [str(input()) for _ in range(n)]
m = int(input())
t = [str(input()) for _ in range(m)]
l = set(s)
num = max((s.count(i) - t.count(i) for i in l))
print(max(0, num))


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
k = set(s)
tot = 0
for i in k:
	tot = max(s.count(i) - t.count(i), tot)
print(tot)


m = int(input())
a1 = [input() for i in range(m)]
n = int(input())
a2 = [input() for i in range(n)]
ans = 0
for i in a1:
	ans = max(ans, a1.count(i) - a2.count(i))
print(ans)


n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
c = [a.count(a[i]) - b.count(a[i]) for i in range(n)]
print(max(max(c), 0))


n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
s = a + b
t = []
for i in s:
	t.append(a.count(i) - b.count(i))
print(0 if max(t) <= 0 else max(t))


a = int(input())
b = list((input() for _ in range(a)))
c = int(input())
d = list((input() for _ in range(c)))
x = []
for i in set(b):
	x += [b.count(i) - d.count(i)]
print(max(max(x), 0))


N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
from collections import Counter
counter = Counter(S)
counter.subtract(T)
print(max(0, max(counter.values())))


d = {}
for _ in range(int(input())):
	s = input()
	d[s] = d.get(s, 0) + 1
for _ in range(int(input())):
	s = input()
	d[s] = d.get(s, 0) - 1
print(max(0, max(d.values())))


from collections import defaultdict
d = defaultdict(int)
for i in range(int(input())):
	d[input()] += 1
for i in range(int(input())):
	d[input()] -= 1
print(max(max((d[i] for i in d)), 0))


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
a = 0
for x in set(s):
	a = max(s.count(x) - t.count(x), a)
print(a)


N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ans = [s.count(si) - t.count(si) for si in set(s)]
print(max(0, max(ans)))


N = int(input())
n_list = []
for i in range(N):
	n_list.append(input())
M = int(input())
m_list = []
for i in range(M):
	m_list.append(input())
add_dic = {}
for n in n_list:
	add = add_dic.get(n, 0)
	add_dic[n] = add + 1
diff_dic = {}
for m in m_list:
	diff = diff_dic.get(m, 0)
	diff_dic[m] = diff + 1
max_ = 0
for (key, add) in add_dic.items():
	total = add - diff_dic.get(key, 0)
	if total > max_:
		max_ = total
print(max_)


from collections import Counter
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for i in range(m)]
s = Counter(s)
t = Counter(t)
ans = 0
for i in list(s.keys()):
	if i in t:
		ans_tmp = s[i] - t[i]
	else:
		ans_tmp = s[i]
	ans = max(ans, ans_tmp)
print(ans)


N = int(input())
Blue = [input() for _ in range(N)]
M = int(input())
Red = [input() for _ in range(M)]
Word = Blue + Red
Word = list(set(Word))
ans = 0
for i in range(len(Word)):
	cnt = 0
	cnt += Blue.count(Word[i])
	cnt -= Red.count(Word[i])
	ans = max(ans, cnt)
print(ans)


d = {'': 0}
for _ in [0] * int(input()):
	e = input()
	d[e] = d.get(e, 0) + 1
for _ in [0] * int(input()):
	e = input()
	d[e] = d.get(e, 0) - 1
print(max(d.values()))


n = int(input())
blue = [input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
print(max(max([blue.count(blue[i]) - red.count(blue[i]) for i in range(n)]), 0))


from collections import Counter
N = int(input())
A = Counter((input() for _ in range(N)))
M = int(input())
for _ in range(M):
	A[input()] -= 1
print(max(max(A.values()), 0))


N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
ret = 0
for s in set(S):
	ret = max(ret, S.count(s) - T.count(s))
print(ret)


from collections import Counter
s = Counter((input() for i in range(int(input()))))
t = Counter((input() for i in range(int(input()))))
print(max([0] + [s[i] - t[i] for i in s.keys()]))


n = int(input())
ans = 0
count = 0
s = {}
t = {}
for i in range(n):
	a = input()
	if a not in s:
		s[a] = 1
	else:
		s[a] += 1
m = int(input())
for i in range(m):
	a = input()
	if a not in t:
		t[a] = 1
	else:
		t[a] += 1
S = list(s.keys())
T = list(t.keys())
for i in range(len(S)):
	if S[i] in T:
		count = s[S[i]] - t[S[i]]
	else:
		count = s[S[i]]
	ans = max(ans, count)
print(ans)


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for j in range(m)]
c = 0
for k in s:
	a = s.count(k) - t.count(k)
	if a > c:
		c = a
print(c)


N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
u = set(s)
ans = 0
for i in u:
	temp = s.count(i) - t.count(i)
	ans = max(ans, temp)
print(ans)


from collections import Counter
import math
import statistics
import itertools
a = int(input())
g = [input() for _ in range(a)]
b = int(input())
g2 = [input() for _ in range(b)]
g.sort()
g2.sort()
count = 1
ans = {}
ans2 = {}
for i in range(len(g) - 1):
	if g[i + 1] == g[i]:
		count += 1
	else:
		ans[g[i]] = count
		count = 1
ans[g[-1]] = count
count = 1
for i in range(len(g2) - 1):
	if g2[i + 1] == g2[i]:
		count += 1
	elif g2[i] in list(ans.keys()):
		ans[g2[i]] -= count
		count = 1
	else:
		ans[g2[i]] = -count
if g2[-1] in list(ans.keys()):
	ans[g2[-1]] -= count
	count = 1
else:
	ans[g2[-1]] = -count
if max(ans.values()) > 0:
	print(max(ans.values()))
else:
	print(0)


N = int(input())
blue = [input() for _ in range(N)]
M = int(input())
red = [input() for _ in range(M)]
set_blue = set(blue)
scores = []
for s in set_blue:
	score = blue.count(s) - red.count(s)
	scores.append(score)
ms = max(scores)
if ms >= 0:
	print(ms)
else:
	print(0)


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
print(max(0, max((s.count(w) - t.count(w) for w in set(s)))))


N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
cnt = 0
for x in s:
	cnt = max(s.count(x) - t.count(x), cnt)
print(cnt)


from typing import List

def answer(n: int, s: List[str], m: int, t: List[str]) -> int:
	result = 0
	for i in s:
		result = max(result, s.count(i) - t.count(i))
	return result

def main():
	n = int(input())
	s = [input() for _ in range(n)]
	m = int(input())
	t = [input() for _ in range(m)]
	print(answer(n, s, m, t))

def __starting_point():
	main()
__starting_point()


n = int(input())
sl = [input() for _ in range(n)]
m = int(input())
tl = [input() for _ in range(m)]
ans = 0
for s in sl:
	ans = max(ans, sl.count(s) - tl.count(s))
print(ans)


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ss = tuple(s)
ans = 0
for si in ss:
	ans = max(ans, s.count(si) - t.count(si))
print(ans)


n = int(input())
sl = list((input() for _ in range(n)))
m = int(input())
tl = list((input() for _ in range(m)))
sl_s = list(set(sl))
tl_s = list(set(tl))
ans = 0
for s in sl_s:
	ans = max(ans, sl.count(s) - tl.count(s))
print(ans)


(r1, r2) = ([input() for _ in range(int(input()))], [input() for _ in range(int(input()))])
ans = 0
ans = [r1.count(i) - r2.count(i) for i in set(r1)]
print(max(0, max(ans)))


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
s1 = set(s)
t1 = set(t)
ans = 0
for i in s1:
	ans = max(ans, s.count(i) - t.count(i))
print(ans)


N = int(input())
S = list((input() for i in range(N)))
M = int(input())
T = list((input() for i in range(M)))
z = [0]
for s in S:
	z.append(S.count(s) - T.count(s))
print(max(z))


n = int(input())
list_s = [input() for i in range(0, n)]
m = int(input())
list_t = [input() for i in range(0, m)]
dict_blue = {}
dict_red = {}
list_ans = []
for i in range(0, n):
	if list_s[i] in dict_blue:
		pass
	else:
		dict_blue[list_s[i]] = list_s.count(list_s[i])
for i in range(0, m):
	if list_t[i] in dict_red:
		pass
	else:
		dict_red[list_t[i]] = list_t.count(list_t[i])
for (key, value) in dict_blue.items():
	if key in dict_red.keys():
		list_ans.append(value - dict_red[key])
	else:
		list_ans.append(value)
if max(list_ans) > 0:
	print(max(list_ans))
else:
	print(0)


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
money = 0
for word in s:
	money = max(money, s.count(word) - t.count(word))
print(money)


N = int(input())
dic = {}
for i in range(N):
	word = input()
	if word in dic:
		dic[word] += 1
	else:
		dic[word] = 1
M = int(input())
for i in range(M):
	word = input()
	if word in dic:
		dic[word] -= 1
	else:
		dic[word] = -1
ans = 0
for i in dic:
	ans = max(ans, dic[i])
print(ans)


N = int(input())
S = list((input() for x in range(N)))
M = int(input())
T = list((input() for y in range(M)))
count = []
for n in range(N):
	count.append(S.count(S[n]) - T.count(S[n]))
max_count = max(count)
if max_count < 0:
	print(0)
else:
	print(max_count)


N = int(input())
s = dict()
for _ in range(N):
	S = input()
	if S not in s:
		s[S] = 0
	s[S] += 1
M = int(input())
for _ in range(M):
	t = input()
	if t in s:
		s[t] -= 1
print(max((max(0, x) for x in list(s.values()))))


N = int(input())
L = [input() for i in range(N)]
M = int(input())
S = [input() for i in range(M)]
A = [0]
for i in range(N):
	A.append(L.count(L[i]) - S.count(L[i]))
print(max(A))


n = [input() for i in range(int(input()))]
m = [input() for i in range(int(input()))]
l = list(set(n))
x = 0
for i in l:
	y = max(0, n.count(i) - m.count(i))
	if y > x:
		x = y
print(x)


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
s1 = set(s)
a = b = 0
for ss in s1:
	a = s.count(ss) - t.count(ss)
	if a > b:
		b = a
print(b)


N = int(input())
A = [input() for _ in range(N)]
M = int(input())
B = [input() for _ in range(M)]
ans = 0
for w in set(A):
	ans = max(ans, A.count(w) - B.count(w))
print(ans)


n = int(input())
S = []
T = []
data = set()
for i in range(n):
	s = input()
	S.append(s)
	data.add(s)
m = int(input())
for i in range(m):
	t = input()
	T.append(t)
	data.add(t)
ans = 0
for i in data:
	ans = max(ans, S.count(i) - T.count(i))
print(ans)


from collections import defaultdict
cnt = defaultdict(int)
cnt[0] = 0
N = int(input())
for _ in range(N):
	cnt[input()] += 1
M = int(input())
for _ in range(M):
	cnt[input()] -= 1
print(max((v for v in list(cnt.values()))))


N = int(input())
s = []
for i in range(N):
	s.append(input())
M = int(input())
t = []
for i in range(M):
	t.append(input())
money_list = []
for i in range(N):
	money = s.count(s[i]) - t.count(s[i])
	money_list.append(money)
ans = max(money_list)
if ans < 0:
	print('0')
else:
	print(ans)


blue = [input() for i in range(int(input()))]
red = [input() for i in range(int(input()))]
c = 0
for i in blue:
	a = blue.count(i) - red.count(i)
	if a > 0 and a > c:
		c = a
print(c)


I = lambda : [input() for _ in [0] * int(input())]
s = I()
t = I()
print(max(0, *[s.count(i) - t.count(i) for i in s]))


N = int(input())
S = []
for i in range(N):
	s = input()
	S.append(s)
M = int(input())
T = []
for i in range(M):
	t = input()
	T.append(t)
ans = -1
x = 0
for i in S:
	x = S.count(i) - T.count(i)
	ans = max(ans, x)
if ans < 0:
	ans = 0
print(ans)


Ns = [input() for _ in range(int(input()))]
Ms = [input() for _ in range(int(input()))]
l = list(set(Ns))
print(max(0, max((Ns.count(l[i]) - Ms.count(l[i]) for i in range(len(l))))))


from math import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import bisect
import heapq
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
n = I()
s = Counter([input() for _ in range(n)])
m = I()
t = Counter([input() for _ in range(m)])
ans = 0
for (k, v) in list(s.items()):
	ans = max(ans, max(0, v - t[k]))
print(ans)


n = int(input())
s = [input() for i in range(n)]
m = int(input())
p = [input() for i in range(m)]
q = 0
for i in range(n):
	d = s.count(s[i]) - p.count(s[i])
	if d > q:
		q = d
print(q)


ans = 0
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
for i in set(s):
	p = s.count(i) - t.count(i)
	ans = max(ans, p)
print(ans)


from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)
n = int(input())
for i in range(n):
	d1[input()] += 1
m = int(input())
for i in range(m):
	d2[input()] += 1
ans = 0
for (k, v) in list(d1.items()):
	ans = max(ans, v - d2[k])
print(ans)


N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
A = 0
for i in S:
	A = max(S.count(i) - T.count(i), A)
print(A)


N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
a_list = list(set(s))
test_count = 0
for i in range(len(a_list)):
	x = a_list[i]
	if test_count <= s.count(x) - t.count(x):
		test_count = s.count(x) - t.count(x)
print(test_count)


n = int(input())
s_l = [str(input()) for _ in range(n)]
m = int(input())
t_l = [str(input()) for _ in range(m)]
d = {}
for s in s_l:
	if s not in d:
		d[s] = 1
	else:
		d[s] += 1
for t in t_l:
	if t not in d:
		d[t] = -1
	else:
		d[t] -= 1
ans = 0
for (k, v) in d.items():
	ans = max(v, ans)
print(ans)


N = int(input())
si = [input() for _ in range(N)]
M = int(input())
ti = [input() for _ in range(M)]
cnt = 0
for s in si:
	cnt = max(si.count(s) - ti.count(s), cnt)
print(cnt)


a = []
b = []
m = 0
for _ in [0] * int(input()):
	a += [input()]
for _ in [0] * int(input()):
	b += [input()]
for s in a:
	m = max(m, a.count(s) - b.count(s))
print(m)


from collections import Counter
n = int(input())
s = Counter([input() for _ in range(n)])
m = int(input())
t = Counter([input() for _ in range(m)])
for (x, y) in s.items():
	s[x] = s[x] - t[x]
print(max(max(list(s.values())), 0))


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
lis = set(s)
print(max(0, max([s.count(l) - t.count(l) for l in lis])))


N = [input() for i in range(int(input()))]
M = [input() for i in range(int(input()))]
L = list(set(N))
print(max(0, max((N.count(L[j]) - M.count(L[j]) for j in range(len(L))))))


(s, t) = ([], [])
for i in range(int(input())):
	s.append(input())
for i in range(int(input())):
	t.append(input())
profit = 0
for i in s:
	temp = s.count(i) - t.count(i)
	if profit < temp:
		profit = temp
print(profit)


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
li = list(set(s))
print(max(0, max((s.count(li[i]) - t.count(li[i]) for i in range(len(li))))))


n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
l = list(set(n))
print(max(0, max((n.count(t) - m.count(t) for t in l))))


blue = [input() for i in range(int(input()))]
red = [input() for i in range(int(input()))]
print(max(0, max([blue.count(i) - red.count(i) for i in set(blue + red)])))


Blue = []
Red = []
n = int(input())
for i in range(n):
	s = input()
	Blue.append(s)
m = int(input())
for i in range(m):
	t = input()
	Red.append(t)
ans = 0
for a in Blue:
	plus = Blue.count(a)
	minus = Red.count(a)
	point = plus - minus
	ans = max(ans, point)
print(ans)


from collections import Counter
N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]
M = int(input())
T = [''.join(sorted(input())) for _ in range(M)]
s = Counter(S)
t = Counter(T)
ans = 0
for (k, v) in list(s.items()):
	tmp = v
	tmp -= t[k]
	ans = max(ans, tmp)
print(ans)


n = int(input())
s = [input() for _ in [0] * n]
m = int(input())
t = [input() for _ in [0] * m]
print(max([s.count(x) - t.count(x) for x in s] + [0]))


n = int(input())
b = [input() for _ in range(n)]
m = int(input())
r = [input() for _ in range(m)]
l = list(set(b))
a = []
for s in l:
	a.append(b.count(s) - r.count(s))
print(max(max(a), 0))


s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
l = set(s)
M = []
for i in l:
	M.append(s.count(i) - t.count(i))
print(max(0, max(M)))


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
u = set(s)
ans = 0
for i in u:
	cnt = s.count(i) - t.count(i)
	ans = max(ans, cnt)
print(ans)


def l():
	return [input() for _ in range(int(input()))]
(p, m) = (l(), l())
c = 0
for s in set(p):
	c = max(p.count(s) - m.count(s), c)
print(c)


n = int(input())
s = [''] * n
for i in range(n):
	s[i] = input()
import collections
s = collections.Counter(s)
m = int(input())
for j in range(m):
	t = input()
	if t in s:
		s[t] -= 1
print(max(0, s.most_common()[0][1]))


from collections import defaultdict
(Blue, Red) = (defaultdict(int), defaultdict(int))
N = int(input())
for _ in range(N):
	Blue[input()] += 1
M = int(input())
for _ in range(M):
	Red[input()] += 1
ans = 0
for (word, cnt) in list(Blue.items()):
	temp = cnt - Red[word]
	ans = max(ans, temp)
print(ans)


N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
s_set = list(set(s))
maxim = 0
for i in s_set:
	count = 0
	for j in s:
		if i == j:
			count += 1
	for k in t:
		if i == k:
			count -= 1
	if maxim < count:
		maxim = count
print(maxim)


from collections import defaultdict
cnt = defaultdict(int)
cnt['a' * 11] = 0
for _ in range(int(input())):
	cnt[input()] += 1
for _ in range(int(input())):
	cnt[input()] -= 1
ans = max(cnt.values())
print(ans)


n = int(input())
s = [input() for s in range(n)]
m = int(input())
t = [input() for i in range(m)]
plus = []
minus = []
total = []
for i in set(s):
	plus.append(s.count(i))
	minus.append(t.count(i))
for j in range(len(plus)):
	total.append(plus[j] - minus[j])
print(max(0, max(total)))


n = int(input())
S = list((input() for _ in range(n)))
m = int(input())
T = list((input() for _ in range(m)))
L = set(S)
print(max(0, max((S.count(l) - T.count(l) for l in L))))


from collections import defaultdict
n = int(input())
s = defaultdict(int)
t = defaultdict(int)
for i in range(n):
	x = input()
	s[x] += 1
m = int(input())
for i in range(m):
	x = input()
	t[x] += 1
ans = 0
for (x, v) in list(s.items()):
	now = v - t[x]
	ans = max(ans, now)
print(ans)


blue = []
red = []
ans = 0
n = int(input())
for i in range(n):
	blue.append(input())
m = int(input())
for j in range(m):
	red.append(input())
word = set(blue)
for k in word:
	c = blue.count(k) - red.count(k)
	ans = max(ans, c)
print(ans)


h = {'': 0}
for i in [1, -1]:
	for _ in range(int(input())):
		s = input()
		if s in h:
			h[s] += i
		else:
			h[s] = i
print(max(h.values()))


from collections import Counter
from sys import stdin

def input():
	return stdin.readline().strip()
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
s = Counter(s)
t = Counter(t)
ans = 0
for (key, num) in s.items():
	if key in t:
		if ans < num - t[key]:
			ans = num - t[key]
	elif ans < num:
		ans = num
print(ans)


n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
l = set(a)
e = -100000
for i in l:
	e = max(e, a.count(i) - b.count(i))
print(max(e, 0))


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
sc = list(set(s.copy()))
from collections import Counter
sn = Counter(s)
tn = Counter(t)
for i in range(len(sc)):
	ans = max(sn[sc[i]] - tn[sc[i]], ans)
print(ans)


S = [input() for _ in range(int(input()))]
T = [input() for _ in range(int(input()))]
l = list(set(S))
print(max(0, max((S.count(l[i]) - T.count(l[i]) for i in range(len(l))))))


n = int(input())
s = [input().split() for _ in range(n)]
m = int(input())
t = [input().split() for _ in range(m)]
ans = -100
for i in s:
	ans = max(ans, s.count(i) - t.count(i))
if ans < 0:
	ans = 0
print(ans)


bag = {}
N = int(input())
for _ in range(N):
	s = input()
	if s in bag:
		bag[s] += 1
	else:
		bag[s] = 1
M = int(input())
for _ in range(M):
	s = input()
	if s in bag:
		bag[s] -= 1
d_swap = {v: k for (k, v) in list(bag.items())}
if max(d_swap) < 0:
	print(0)
else:
	print(max(d_swap))


n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
ans = 0
for ai in set(a):
	n = a.count(ai) - b.count(ai)
	if n > ans:
		ans = n
print(ans)


d = {}
for _ in [0] * int(input()):
	e = input()
	d[e] = d.get(e, 0) + 1
for _ in [0] * int(input()):
	e = input()
	d[e] = d.get(e, 0) - 1
print(max(d[max(d, key=lambda x: d[x])], 0))


n = int(input())
t = [input() for i in range(n)]
m = int(input())
q = [input() for i in range(m)]
z = set(t)
base = [0]
for i in z:
	base.append(t.count(i) - q.count(i))
print(max(base))


b = int(input())
a = [input() for i in range(b)]
r = int(input())
c = [input() for i in range(r)]
cnt = 0
for i in range(b):
	cnt = max(cnt, a.count(a[i]) - c.count(a[i]))
print(cnt)


n = int(input())
blue = []
for i in range(n):
	blue.append(input())
m = int(input())
red = []
for i in range(m):
	red.append(input())
scores = []
for i in range(len(blue)):
	score = blue.count(blue[i]) - red.count(blue[i])
	scores.append(score)
if max(scores) < 0:
	print(0)
else:
	print(max(scores))


N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
mx = 0
for ss in s:
	mx = max(s.count(ss) - t.count(ss), mx)
print(mx)


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
c = Counter(s).most_common()
d = Counter(t)
p = -1000
for (k, v) in c:
	p = max(p, v - d[k])
print(max(p, 0))


from collections import *
c = Counter({0: 0})
for i in (1, -1):
	for _ in range(int(input())):
		c[input()] += i
print(max(c.values()))


n = int(input())
s = list((input() for i in range(n)))
m = int(input())
t = list((input() for i in range(m)))
l = []
for i in s:
	l += [s.count(i) - t.count(i)]
print(max(max(l), 0))


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for j in range(m)]
l = list(set(s))
result = max(0, max((s.count(i) - t.count(i) for i in l)))
print(result)


def resolve():
	n = int(input())
	blue_cards = list()
	for i in range(n):
		card = input()
		blue_cards.append(card)
	blue_cards = sorted(blue_cards)
	m = int(input())
	red_cards = list()
	for i in range(m):
		card = input()
		red_cards.append(card)
	red_cards = sorted(red_cards)
	former = ''
	cards_points = []
	for card in blue_cards:
		point = 0
		if former == card:
			continue
		else:
			p = blue_cards.count(card)
			m = red_cards.count(card)
			point = p - m
			cards_points.append(point)
			former = card
	cards_points = sorted(cards_points)
	if cards_points[-1] < 0:
		print(0)
	else:
		print(cards_points[-1])
resolve()


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
c = 0
for i in set(s):
	d = s.count(i) - t.count(i)
	if d > c:
		c = d
print(c)


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
l = [0]
for i in range(n):
	k = s.count(s[i]) - t.count(s[i])
	l.append(k)
print(max(l))


n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = []
for i in s:
	cnt = 0
	for j in range(n):
		if i == s[j]:
			cnt += 1
	for k in range(m):
		if i == t[k]:
			cnt -= 1
	ans.append(cnt)
if max(ans) < 0:
	print('0')
else:
	print(max(ans))


N = int(input())
s = []
for i in range(N):
	s.append(input())
s.append('')
M = int(input())
t = []
for j in range(M):
	t.append(input())
ans = 0
for i in range(N + 1):
	target = s[i]
	cnt = 0
	for j in range(N):
		if target == s[j]:
			cnt += 1
	for k in range(M):
		if target == t[k]:
			cnt -= 1
	ans = max(ans, cnt)
print(ans)


a = [input() for _ in range(int(input()))]
b = [input() for _ in range(int(input()))]
l = list(set(a))
c = max(0, max([a.count(i) - b.count(i) for i in l]))
print(c)


N = int(input())
Ns = []
for i in range(N):
	Ns.append(input())
M = int(input())
Ms = []
for i in range(M):
	Ms.append(input())
Ws = list(set(Ns + Ms))
As = []
for i in Ws:
	ans = 0
	for j in Ns:
		if i == j:
			ans += 1
	for j in Ms:
		if i == j:
			ans -= 1
	As.append(ans)
print(max(max(As), 0))


N = int(input())
blue = {}
for _ in range(N):
	s = input()
	if s in blue.keys():
		blue[s] += 1
	else:
		blue[s] = 1
M = int(input())
red = {}
for _ in range(M):
	t = input()
	if t in red.keys():
		red[t] += 1
	else:
		red[t] = 1
cnt = 0
for i in blue.keys():
	if i in red.keys():
		cnt = max(cnt, blue[i] - red[i])
	else:
		cnt = max(cnt, blue[i])
print(cnt)


(n, *s) = open(0).read().split()
n = int(n)
print(max(0, *[s[:n].count(i) - s[n:].count(i) for i in s[:n]]))


n = int(input())
ns = [input() for _ in range(n)]
m = int(input())
ms = [input() for _ in range(m)]
l = list(set(ns))
print(max(0, max((ns.count(l[i]) - ms.count(l[i]) for i in range(len(l))))))


red_cards = []
blue_cards = []
N = int(input())
for i in range(N):
	blue_cards.append(input())
M = int(input())
for i in range(M):
	red_cards.append(input())
all_words = set(blue_cards + red_cards)
ans = 0
for (i, w) in enumerate(all_words):
	cnt_b = cnt_r = 0
	for b in blue_cards:
		if b == w:
			cnt_b += 1
	for r in red_cards:
		if r == w:
			cnt_r += 1
	diff = cnt_b - cnt_r
	if diff > ans:
		ans = diff
print(ans)


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
s_set = list(set(s))
win = max((s.count(s_set[i]) - t.count(s_set[i]) for i in range(len(s_set))))
print(max(0, win))


n = int(input())
b = [input() for _ in [0] * n]
m = int(input())
r = [input() for _ in [0] * m]
ans = 0
for s in set(b):
	ans = max([ans, b.count(s) - r.count(s)])
print(ans)


n = int(input())
b = [input() for i in range(n)]
m = int(input())
r = [input() for i in range(m)]
ans = [0]
for i in set(b):
	ans.append(b.count(i) - r.count(i))
print(max(ans))


n = int(input())
blue_cards = []
for i in range(n):
	blue_cards.append(input())
m = int(input())
red_cards = []
for i in range(m):
	red_cards.append(input())
scores = []
for i in range(len(blue_cards)):
	score = blue_cards.count(blue_cards[i]) - red_cards.count(blue_cards[i])
	scores.append(score)
if max(scores) < 0:
	print(0)
else:
	print(max(scores))


import collections
N = int(input())
S = [input() for i in range(N)]
cS = collections.Counter(S)
lS = list(cS.items())
M = int(input())
T = [input() for i in range(M)]
cT = collections.Counter(T)
list1 = []
ans = 0
for i in range(len(lS)):
	if lS[i][0] in cT:
		x = lS[i][1] - cT[lS[i][0]]
	else:
		x = lS[i][1]
	if x > 0:
		list1.append(x)
if list1 == []:
	print(0)
else:
	print(max(list1))


N = int(input())
n = 0
blue = []
while n < N:
	blue.append(input())
	n += 1
M = int(input())
m = 0
red = []
while m < M:
	red.append(input())
	m += 1
set_blue = set(blue)
scores = []
for s in set_blue:
	score = blue.count(s) - red.count(s)
	scores.append(score)
ms = max(scores)
if ms >= 0:
	print(ms)
else:
	print(0)


n = int(input())
s = []
for _ in range(n):
	s.append(str(input()))
m = int(input())
t = []
for _ in range(m):
	t.append(str(input()))
a = []
for i in s:
	if i not in a:
		a.append(i)
for i in t:
	if i not in a:
		a.append(i)
b = []
for i in a:
	x = s.count(i)
	y = t.count(i)
	b.append(x - y)
print(max(0, max(b)))


n = int(input())
b = [input() for _ in range(n)]
m = int(input())
r = [input() for _ in range(m)]
c = 0
for i in b:
	c = max(b.count(i) - r.count(i), c)
print(c)


n = int(input())
sn = [input() for _ in range(n)]
m = int(input())
tm = [input() for _ in range(m)]
print(max([sn.count(x) - tm.count(x) for x in sn] + [0]))


n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
ans = 0
for x in a:
	ans = max(ans, a.count(x) - b.count(x))
print(ans)


import sys, collections
lines = [s.rstrip('\n') for s in sys.stdin.readlines()]
(n,) = [int(num) for num in lines.pop(0).split(' ')]
blue_list = lines[:n]
lines = lines[n:]
(m,) = [int(num) for num in lines.pop(0).split(' ')]
red_list = lines
blue = collections.Counter(blue_list)
red = collections.Counter(red_list)
c = blue - red
lis = list(c.values())
if len(lis):
	ans = max(lis)
else:
	ans = 0
print(ans)


S = [input() for _ in range(int(input()))]
T = [input() for _ in range(int(input()))]
ans = 0
for i in S:
	tmp = S.count(i) - T.count(i)
	if tmp > ans:
		ans = tmp
print(ans)


from collections import Counter
N = int(input())
blue = [input() for _ in range(N)]
M = int(input())
red = [input() for _ in range(M)]
Cb = Counter(blue)
Cr = Counter(red)
ans = 0
for b in Cb.most_common():
	x = b[0]
	y = b[1]
	if Cr.get(x):
		ans = max(ans, y - Cr[x])
	else:
		ans = max(ans, y)
print(ans)


from collections import Counter
a = [input() for _ in range(int(input()))]
b = [input() for _ in range(int(input()))]
c = Counter(a) - Counter(b)
print(max([0] + [v for v in c.values()]))


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
tmp = max([s.count(s[i]) - t.count(s[i]) for i in range(len(s))])
print(max(tmp, 0))