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

Starter code:

Solutions:
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 _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

ans = 0
cnt = 0
for i in set(s):
  cnt = s.count(i) - t.count(i)
  ans = max(ans, cnt)
print(ans)

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())
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())
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())
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())
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)

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
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 _ 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())
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)


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())
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)


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#-float('inf')
for i in dic:
    ans = max(ans, dic[i])
print(ans)

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)

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)]
c = 0
for i in set(s):
    d = s.count(i)-t.count(i)
    if d > c:
        c = d
print(c)

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)))


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))

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 = []
t = []
ans = 0
for i in range(n):
  s.append(input())
m = int(input())
for i in range(m):
  t.append(input())
l = set(s)
for i in l:
  ans = max(ans,s.count(i) - t.count(i))
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)]

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)]

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())
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)))


#B - Two Colors Card Game
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)

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())))

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)))

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()))

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]
    else:
        if ans < num:
            ans = num

print(ans)

from collections import Counter
# ABC091
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)

#!/usr/bin/env python3

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 = [""]*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]))

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)

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())
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())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
li = []
for i in range(n):
    li += [s.count(s[i])-t.count(s[i])]
print(max(max(li),0))

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())
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)

#!/usr/bin/env python3
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)


# -*- coding: utf-8 -*-

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 = []
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())
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())
blue = [input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]

ans = 0
for i in range(n):
    tmp = blue.count(blue[i]) - red.count(blue[i])
    ans = max(ans, tmp)
print(ans)

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 = [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())
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)



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)

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())
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)

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))

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)


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))))


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(i)-t.count(i) for i in set(s)))))
    





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)

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))

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())))

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 = [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 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())
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_)

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)

from collections import Counter
import math
import statistics
import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
g = [input() for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

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
    else:
        if 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())
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)]

ans=0
for i in set(s):
    ans=max(s.count(i)-t.count(i),ans)
print(ans)

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()))

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())
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)]
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)

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=[]
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)

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())
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)


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)

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)

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))

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 = 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)

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)



#!/usr/bin/env python3


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 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())
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)

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

ans = 0
for i in s:
    ans = max(ans,s.count(i)-t.count(i))

print(ans)

n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]

l = list(set(n))

print(max(0,max(n.count(l[i]) - m.count(l[i]) for i in range(len(l)))))

#-*-coding:utf-8-*-
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()

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()

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)

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)


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)


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

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)))


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)

N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

answer = 0
for i in S:
    answer = max(answer, S.count(i) - T.count(i))
print(answer)

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=[]
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

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 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)