There is an array of $n$ integers. There are also $2$ disjoint sets, $\mbox{A}$ and $\mbox{B}$, each containing $m$ integers. You like all the integers in set $\mbox{A}$ and dislike all the integers in set $\mbox{B}$. Your initial happiness is $\mbox{o}$. For each $\boldsymbol{i}$ integer in the array, if $i\in A$, you add $\mbox{I}$ to your happiness. If $i\in B$, you add $-1$ to your happiness. Otherwise, your happiness does not change. Output your final happiness at the end.  

Note: Since $\mbox{A}$ and $\mbox{B}$ are sets, they have no repeated elements. However, the array might contain duplicate elements.  

Constraints 

$1\leq n\leq10^5$ 

$1\leq m\leq10^5$ 

$1\leq\textit{Any integer in the input}\leq10^9$  

Input Format

The first line contains integers $n$ and $m$ separated by a space. 

The second line contains $n$ integers, the elements of the array. 

The third and fourth lines contain $m$ integers, $\mbox{A}$ and $\mbox{B}$, respectively.

Output Format

Output a single integer, your total happiness.

Sample Input
3 2
1 5 3
3 1
5 7

Sample Output
1

Explanation

You gain $\mbox{I}$ unit of happiness for elements $3$ and $\mbox{I}$ in set $\mbox{A}$. You lose $\mbox{I}$ unit for $5$ in set $\mbox{B}$. The element $7$ in set $\mbox{B}$ does not exist in the array so it is not included in the calculation. 

Hence, the total happiness is $2-1=1$.

Difficulty: MEDIUM
Tags: Data structures
Skill types: Data structures

Starter code:

Solutions:
def __starting_point():
	happiness = 0
	(n, m) = map(int, input().strip().split(' '))
	arr = list(map(int, input().strip().split(' ')))
	good = set(map(int, input().strip().split(' ')))
	bad = set(map(int, input().strip().split(' ')))
	for el in arr:
		if el in good:
			happiness += 1
		elif el in bad:
			happiness -= 1
	print(happiness)
__starting_point()


(n, m) = map(int, input().split())
menbers = input().split()
A = set(input().split())
B = set(input().split())
happiness = 0
for i in menbers:
	if i in A:
		happiness += 1
	if i in B:
		happiness -= 1
print(happiness)


(n, m) = (int(i) for i in input().split())
l = map(int, input().strip().split(' '))
a = set(map(int, input().strip().split(' ')))
b = set(map(int, input().strip().split(' ')))
result = 0
for i in l:
	if i in a:
		result += 1
	if i in b:
		result += -1
print(result)


from collections import Counter
sizes = [int(i) for i in input().split()]
array = Counter([int(i) for i in input().split()])
likes = [int(i) for i in input().split()]
dislikes = [int(i) for i in input().split()]
happiness = 0
for i in range(len(likes)):
	happiness += array[likes[i]]
for i in range(len(dislikes)):
	happiness -= array[dislikes[i]]
print(happiness)


(n, m) = list(map(int, input().split()))
n = list(map(int, input().split()))
ma = set(map(int, input().split()))
mb = set(map(int, input().split()))
happiness = 0
for i in n:
	if i in ma:
		happiness += 1
	elif i in mb:
		happiness -= 1
print(happiness)


(n, m) = list(map(int, input().split()))
ns = list(map(int, input().split()))
h = set(map(int, input().split()))
s = set(map(int, input().split()))
res = 0
for x in ns:
	if x in h:
		res += 1
	elif x in s:
		res -= 1
print(res)


(n, m) = map(int, input().split())
if n >= 1 and m >= 1 and (n <= 10 ** 5) and (m <= 10 ** 5):
	c = [int(x) for x in input().split()]
	a = set([int(x) for x in input().split()])
	b = set([int(x) for x in input().split()])
	if len(c) == n and len(a) == len(b) and (len(a) == m):
		happiness = 0
		for i in c:
			if i in a:
				happiness += 1
			elif i in b:
				happiness -= 1
	print(happiness)


import bisect
import sys
next(sys.stdin)
(numbers, a, b) = [list(map(int, sys.stdin.readline().rstrip().split(' '))) for _ in range(3)]
a.sort()
b.sort()
numbers.sort()
deduped = []
curr_num = numbers.pop(0)
curr_num_count = 1
for num in numbers:
	if num == curr_num:
		curr_num_count += 1
	else:
		deduped.append((curr_num, curr_num_count))
		curr_num = num
		curr_num_count = 1
deduped.append((curr_num, curr_num_count))
sum_ = 0
for (num, num_occurrences) in deduped:
	ind = bisect.bisect_left(a, num)
	if ind != len(a) and a[ind] == num:
		sum_ += num_occurrences
	else:
		ind = bisect.bisect_left(b, num)
		if ind != len(b) and b[ind] == num:
			sum_ -= num_occurrences
print(sum_)


from collections import defaultdict
d = defaultdict(int)
h = 0
input()
for n in input().split():
	d[n] += 1
for a in input().split():
	if a in d:
		h += d[a]
for b in input().split():
	if b in d:
		h -= d[b]
print(h)


(n, m) = list(map(int, input().split()))
array = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
happiness = 0
for x in array:
	happiness += 1 if x in A else -1 if x in B else 0
print(happiness)


string = input()
string = string.split()
n = int(string[0])
m = int(string[1])
l = list(map(int, input().split()))
s1 = set(map(int, input().split()))
s2 = set(map(int, input().split()))
happiness = 0
for i in l:
	if i in s1:
		happiness += 1
	elif i in s2:
		happiness -= 1
print(happiness)


from collections import Counter
(n, m) = [int(i) for i in input().split()]
lst = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
c = dict(Counter(lst))
for (i, j) in zip(a, b):
	if i in c:
		ans += c[i]
	if j in c:
		ans -= c[j]
print(ans)


(m, n) = map(int, input().split())
n_val = list(map(int, input().split()))
A_set = set(map(int, input().split()))
B_set = set(map(int, input().split()))
happiness = 0
for val in n_val:
	if val in A_set:
		happiness += 1
	elif val in B_set:
		happiness -= 1
print(happiness)


input()
ns = list(map(int, input().split()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
c = {}
for x in As:
	c[x] = 1
for x in Bs:
	c[x] = -1
print(sum(map(lambda n: c.setdefault(n, 0), ns)))


from sys import stdin
_ = stdin.readline()
ints = map(int, stdin.readline().split())
happy = set(map(int, stdin.readline().split()))
sad = set(map(int, stdin.readline().split()))
happiness = 0
for i in ints:
	if i in happy:
		happiness += 1
	elif i in sad:
		happiness -= 1
print(happiness)


(m, n) = input().split()
(m, n) = (int(m), int(n))
l = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
d = {}
for i in x:
	d[i] = 1
for i in y:
	d[i] = -1
count = 0
for i in l:
	if i in d:
		count += d[i]
print(count)


input()
X = [int(e) for e in input().split()]
A = {int(e) for e in input().split()}
B = {int(e) for e in input().split()}
r = 0
for e in X:
	r += (e in A) - (e in B)
print(r)


from collections import Counter
(n, m) = map(int, input().split(' '))
l = Counter(map(int, input().strip().split(' ')))
s1 = set(map(int, input().strip().split(' ')))
s2 = set(map(int, input().strip().split(' ')))
happy = 0
for i in s1:
	if i in l:
		happy += l[i]
for i in s2:
	if i in l:
		happy += -l[i]
print(happy)


(n, m) = [int(x) for x in input().split()]
li = [int(x) for x in input().split()]
a = set((int(x) for x in input().split()))
b = set((int(x) for x in input().split()))
hapiness = 0
for i in li:
	if i in a:
		hapiness += 1
	elif i in b:
		hapiness -= 1
print(hapiness)


from collections import defaultdict

def def_happy(l, a, b):
	happy = 0
	ddict = defaultdict(int)
	for i in a:
		ddict[i] = 1
	for i in b:
		ddict[i] = -1
	for i in l:
		happy += ddict[i]
	print(happy)
(n, m) = map(int, input().split())
ls = [int(i) for i in input().split()]
up = [int(i) for i in input().split()]
down = [int(i) for i in input().split()]
def_happy(ls, up, down)


num = [int(j) for j in input().split()]
arr = [int(j) for j in input().split()]
A = set([int(j) for j in input().split()])
B = set([int(j) for j in input().split()])
h = 0
for i in range(num[0]):
	if arr[i] in A:
		h = h + 1
	if arr[i] in B:
		h = h - 1
print(h)


temp = list(map(int, input().split()))
(nsize, msize) = (temp[0], temp[1])
array = list(map(int, input().split()))
nset = set(list(map(int, input().split())))
mset = set(list(map(int, input().split())))
happiness = 0
for i in array:
	if i in nset:
		happiness += 1
	elif i in mset:
		happiness -= 1
print(happiness)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
result = 0
for i in l:
	if i in A:
		result += 1
	if i in B:
		result -= 1
print(result)


input()
i = [int(item) for item in input().split()]
(a, b) = ({int(item) for item in input().split()} for _ in range(2))
happiness = 0
for number in i:
	if number in a:
		happiness += 1
	elif number in b:
		happiness -= 1
print(happiness)


counters = input()
array = input().split()
like = {x for x in input().split()}
dislike = {x for x in input().split()}
happiness = 0
for x in array:
	if x in like:
		happiness += 1
	elif x in dislike:
		happiness -= 1
print(happiness)


(n, m) = map(int, input().split())
nums = map(int, input().split())
positive = set(map(int, input().split()))
negative = set(map(int, input().split()))
happiness = 0
for num in nums:
	if num in positive:
		happiness += 1
	elif num in negative:
		happiness -= 1
print(happiness)


import collections
(n, m) = map(int, str(input()).split())
array = list(str(input()).split())
A = list(set(str(input()).split()))
B = list(set(str(input()).split()))
happiness = 0
cnt = collections.Counter()
for word in array:
	cnt[word] += 1
for word in A:
	happiness += cnt[word]
for word in B:
	happiness -= cnt[word]
print(happiness)


(n, m) = map(int, input().split())
arr = map(int, input().split())
A = set(map(int, input().split()))
B = set(map(int, input().split()))
cpt = 0
for v in arr:
	if v in A:
		cpt += 1
	elif v in B:
		cpt -= 1
print(cpt)


import collections
counter = collections.Counter()
(n, m) = input().split()
array = input().split()
a = set(input().split())
b = set(input().split())
happiness = 0
for i in range(len(array)):
	counter[array[i]] = counter[array[i]] + 1
for x in a.__iter__():
	happiness += counter[x]
for x in b.__iter__():
	happiness -= counter[x]
print(happiness)


(n, m) = (int(x) for x in input().split())
the_array = [int(x) for x in input().split()]
set_a = {int(x) for x in input().split()}
set_b = {int(x) for x in input().split()}
happiness = 0
for element in the_array:
	if element in set_a:
		happiness += 1
	elif element in set_b:
		happiness -= 1
print(happiness)


(n, m) = input().split()
arrstr = input().split()
arr = [int(arrstr[k]) for k in range(0, int(n))]
arrAstr = input().split()
arrBstr = input().split()
setA = set((int(arrAstr[k]) for k in range(0, int(m))))
setB = set((int(arrBstr[k]) for k in range(0, int(m))))
happ = 0
for k in arr:
	if k in setA:
		happ += 1
	elif k in setB:
		happ -= 1
print(happ)


input()
n = input().split()
a = set(input().split())
b = set(input().split())
happiness = 0
for i in n:
	if i in a:
		happiness += 1
	elif i in b:
		happiness -= 1
print(happiness)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
a = set(map(int, input().split()))
b = set(map(int, input().split()))
t = 0
for i in l:
	if i in a:
		t += 1
	elif i in b:
		t -= 1
print(t)


input()
li = list(map(int, input().strip().split(' ')))
sets = [set(map(int, input().strip().split(' '))) for _ in range(2)]
res = len([0 for e in li if e in sets[0]]) - len([0 for e in li if e in sets[1]])
print(res)


f = input()
N = list(map(lambda x: int(x), input().split()))
A = set(map(lambda x: int(x), input().split()))
B = set(map(lambda x: int(x), input().split()))
H = 0
for i in N:
	if i in A:
		H += 1
	if i in B:
		H -= 1
print(H)


from collections import Counter
(n, m) = list(map(int, input().split()))
ar = list(map(int, input().split()))
ar_set = set(ar)
ar_counter = Counter(ar)
set_a = set(map(int, input().split()))
set_b = set(map(int, input().split()))
intersect_ar_a = list(ar_set & set_a)
intersect_ar_b = list(ar_set & set_b)
result = 0
for element in intersect_ar_a:
	result += ar_counter[element]
for element in intersect_ar_b:
	result -= ar_counter[element]
print(result)


_ = input()
n = list(map(int, input().strip().split(' ')))
a = set(map(int, input().strip().split(' ')))
b = set(map(int, input().strip().split(' ')))
print(sum((1 if x in a else -1 if x in b else 0 for x in n)))


(n, m) = map(int, input().split())
a = list()
b = set()
c = set()
for val in input().split():
	a.append(int(val))
for val in input().split():
	b.add(int(val))
for val in input().split():
	c.add(int(val))
ans = 0
for val in a:
	if val in b:
		ans += 1
	if val in c:
		ans += -1
print(ans)


(n, m) = map(int, input().strip().split(' '))
d = list(map(int, input().strip().split(' ')))
A = list(map(int, input().strip().split(' ')))
B = list(map(int, input().strip().split(' ')))
d.sort()
A.sort()
B.sort()

def A_contains(val):
	imin = 0
	imax = len(A) - 1
	while imax - imin > 3:
		imid = (imin + imax) // 2
		if A[imid] < val:
			imin = imid
		else:
			imax = imid
	while imax >= imin:
		if A[imax] == val:
			return True
		imax = imax - 1
	return False

def B_contains(val):
	imin = 0
	imax = len(B) - 1
	while imax - imin > 3:
		imid = (imin + imax) // 2
		if B[imid] < val:
			imin = imid
		else:
			imax = imid
	while imax >= imin:
		if B[imax] == val:
			return True
		imax = imax - 1
	return False
out = 0
for i in range(0, n):
	if A_contains(d[i]):
		out = out + 1
	if B_contains(d[i]):
		out = out - 1
print(out)


nums = input().split()
(n, m) = (nums[0], nums[1])
arr = input().split()
A = input().split()
B = input().split()
happy = 0
setA = set(A)
setB = set(B)
for x in arr:
	if x in setA:
		happy += 1
	elif x in setB:
		happy -= 1
print(happy)


(n, m) = map(int, input().split())
nIntegers = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
happiness = 0
for i in range(0, n):
	if nIntegers[i] in A:
		happiness += 1
	elif nIntegers[i] in B:
		happiness -= 1
print(happiness)


input()
import collections
count = collections.Counter()
Data = [int(i) for i in input().split()]
Good = [int(i) for i in input().split()]
Bad = [int(i) for i in input().split()]
result = 0
for i in Data:
	count[i] += 1
for i in Good:
	result += count[i]
for i in Bad:
	result -= count[i]
print(result)


[n, m] = list(map(int, input().split()))
arr = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
score = 0
for el in arr:
	if el in A:
		score += 1
	elif el in B:
		score -= 1
print(score)


import collections
(n, m) = input().split()
n = int(n)
m = int(m)
l = list(map(int, input().split()))
repeated_l = {item: count for (item, count) in collections.Counter(l).items() if count > 1}
A = set(list(map(int, input().split())))
B = set(list(map(int, input().split())))
happiness = 0
happiness += len(A.intersection(l))
happiness -= len(B.intersection(l))
for (key, val) in repeated_l.items():
	if key in A:
		happiness += val - 1
	elif key in B:
		happiness -= val - 1
print(happiness)


(n, m) = map(int, input().split())
arr = input().split()
A = set(input().split())
B = set(input().split())
hap = 0
for i in arr:
	if i in A:
		hap += 1
	elif i in B:
		hap -= 1
print(hap)


(n, m) = input().split()
(n, m) = (int(n), int(m))
arr = input().split()
A = set(input().split())
B = set(input().split())
happ = 0
for i in range(0, n):
	if arr[i] in A:
		happ += 1
	elif arr[i] in B:
		happ += -1
print(happ)


def line_to_int_array(line):
	numbers_as_strings = line.split()
	return [int(number) for number in numbers_as_strings]

def score(num, like, dislike):
	if num in like:
		return 1
	elif num in dislike:
		return -1
	else:
		return 0

def main():
	(n, m) = line_to_int_array(input())
	array = line_to_int_array(input())
	assert len(array) == n
	like = set(line_to_int_array(input()))
	assert len(like) == m
	dislike = set(line_to_int_array(input()))
	assert len(dislike) == m
	print(sum((score(num, like, dislike) for num in array)))
main()


input()
arr = input().split()
a = set(input().split())
b = set(input().split())

def health(x):
	if x in a:
		return 1
	if x in b:
		return -1
	return 0
print(sum(map(health, arr)))


input()
arr = list(map(int, input().split()))
happy = set(map(int, input().split()))
unhappy = set(map(int, input().split()))
happiness = 0
for i in arr:
	if i in happy:
		happiness += 1
		continue
	if i in unhappy:
		happiness -= 1
print(happiness)


import sys
(n, m) = sys.stdin.readline().split(' ')
try:
	n = int(n)
	m = int(m)
except:
	print('n or m not ints')
	sys.exit(1)
arr = sys.stdin.readline().strip().split(' ')
like_tmp = sys.stdin.readline().strip().split(' ')
dislike_tmp = sys.stdin.readline().strip().split(' ')
like = {}
dislike = {}
for x in like_tmp:
	like[x] = 1
for x in dislike_tmp:
	dislike[x] = 1
happiness = 0
for i in arr:
	if i in like:
		happiness += 1
	if i in dislike:
		happiness -= 1
print(happiness)


(n, m) = input().replace('\r', '').strip().split(' ')
arr = list(input().replace('\r', '').strip().split(' '))
A = set(input().replace('\r', '').strip().split(' '))
B = set(input().replace('\r', '').strip().split(' '))
erg = 0
for a in arr:
	if a in A:
		erg += 1
	elif a in B:
		erg -= 1
print(erg)


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
happiness = 0
for i in arr:
	if {i} & A:
		happiness += 1
	elif {i} & B:
		happiness -= 1
print(happiness)


(n, m) = tuple(map(int, input().split()))
ints = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
happiness = 0
for i in ints:
	if i in A:
		happiness += 1
	if i in B:
		happiness -= 1
print(happiness)


input()
arr = [int(x) for x in input().split()]
pos = set([int(x) for x in input().split()])
neg = set([int(x) for x in input().split()])
print(sum((1 for x in arr if x in pos)) - sum((1 for x in arr if x in neg)))


from collections import Counter
(N, M) = [int(x) for x in input().split()]
n = [int(x) for x in input().split()]
A = Counter((int(x) for x in input().split()))
B = Counter((int(x) for x in input().split()))
happiness = 0
for num in n:
	if num in A:
		happiness += 1
	elif num in B:
		happiness -= 1
print(happiness)


input()
xs = list(map(int, input().split()))
good = set(map(int, input().split()))
bad = set(map(int, input().split()))
happiness = 0
for x in xs:
	if x in good:
		happiness += 1
	elif x in bad:
		happiness -= 1
print(happiness)


input()
nums = map(int, input().split())
setA = set(map(int, input().split()))
setB = set(map(int, input().split()))
happiness = sum([(lambda n: 1 if n in setA else -1 if n in setB else 0)(num) for num in nums])
print(happiness)


from collections import Counter
(n, m) = [int(x) for x in input().split()]
ar = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
hp = 0
cPos = Counter(A)
cNeg = Counter(B)
car = Counter(ar)
for i in cPos & car:
	hp += car[i]
for i in cNeg & car:
	hp -= car[i]
print(hp)


(_, L) = (input(), tuple(map(int, input().split())))
(A, B) = ({int(x) for x in input().split()}, {int(y) for y in input().split()})
XD = 0
for i in L:
	if i in A:
		XD += 1
	elif i in B:
		XD -= 1
print(XD)


input()
i = input().strip().split(' ')
a = set(input().strip().split(' '))
b = set(input().strip().split(' '))
happiness = 0
for n in i:
	if n in a:
		happiness += 1
for n in i:
	if n in b:
		happiness -= 1
print(happiness)


import sys
from collections import Counter
happy = 0
(n, m) = map(int, sys.stdin.readline().split())
i = Counter([int(x) for x in sys.stdin.readline().split()])
A = [int(x) for x in sys.stdin.readline().split()]
B = [int(x) for x in sys.stdin.readline().split()]
for a in A:
	happy += i[a]
for b in B:
	happy -= i[b]
print(happy)


def generate_hapiness(good, bad):

	def hpns(x):
		if x in good:
			return 1
		elif x in bad:
			return -1
		else:
			return 0
	return hpns
(n, m) = map(int, input().strip().split())
S = map(int, input().strip().split())
A = set(map(int, input().strip().split()))
B = set(map(int, input().strip().split()))
hapiness = generate_hapiness(good=A, bad=B)
print(sum((hapiness(x) for x in S)))


N = input().split()
arr = []
temp = input().split()
for x in range(0, int(N[0])):
	arr.append(temp[x])
temp1 = input().split()
temp2 = input().split()
A = dict()
B = dict()
for x in range(0, int(N[1])):
	A[temp1[x]] = 1
	A[temp2[x]] = -1
Util = 0
for x in arr:
	Util = Util + A.get(x, 0)
print(Util)


(N, M) = input().split(' ')
array = list()
array = input().split(' ')
A = list()
A = input().split(' ')
B = list()
B = input().split(' ')
dic = dict()
for x in A:
	if x != '':
		x = int(x)
		dic[x] = 1
for x in B:
	if x != '':
		x = int(x)
		if x in dic:
			dic[x] = 0
		else:
			dic[x] = -1
result = 0
for x in array:
	if x != '':
		x = int(x)
		if x in dic:
			result += dic[x]
print(result)


(n, m) = [int(i) for i in input().strip().split(' ')]
a = [int(i) for i in input().strip().split(' ')]
b = [int(i) for i in input().strip().split(' ')]
c = [int(i) for i in input().strip().split(' ')]
like = set(b)
hate = set(c)
s = 0
for x in a:
	if x in like:
		s += 1
	elif x in hate:
		s -= 1
print(s)


def main():
	(n, m) = tuple(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	A = set(map(int, input().strip().split()))
	B = set(map(int, input().strip().split()))
	happiness = 0
	for x in arr:
		if x in A:
			happiness += 1
		if x in B:
			happiness -= 1
	print(happiness)
main()


happiness = 0
dim = input().split()
arr = tuple(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
for i in arr:
	if i in A:
		happiness += 1
	elif i in B:
		happiness -= 1
print(happiness)


def solution():
	[n, m] = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	A = set([int(i) for i in input().split()])
	B = set([int(i) for i in input().split()])
	happiness = 0
	for j in a:
		if j in A:
			happiness += 1
		elif j in B:
			happiness -= 1
	print(happiness)
solution()


tmp = input()
tmp = input()
allitems = list(map(int, tmp.split()))
tmp = input()
likes = set(map(int, tmp.split()))
tmp = input()
dislikes = set(map(int, tmp.split()))
happiness = 0
for item in allitems:
	if item in likes:
		happiness += 1
	elif item in dislikes:
		happiness -= 1
print(happiness)


(n, m) = map(int, input().split())
array = [int(e) for e in input().split()]
a = set([int(e) for e in input().split()])
b = set([int(e) for e in input().split()])
sum = 0
for i in range(n):
	if array[i] in a:
		sum = sum + 1
	elif array[i] in b:
		sum = sum - 1
print(sum)


(n, m) = list(map(int, input().split()))
lis = list(map(int, input().split()))
A = set(list(map(int, input().split())))
B = set(list(map(int, input().split())))
h = 0
for x in lis:
	if x in A:
		h += 1
	if x in B:
		h -= 1
print(h)


(n, m) = input().strip().split()
n = int(n)
m = int(m)
arr = [int(elem) for elem in input().split()]
A = {int(elem) for elem in input().split()}
B = {int(elem) for elem in input().split()}
output = 0
for i in range(len(arr)):
	if arr[i] in A:
		output += 1
	elif arr[i] in B:
		output -= 1
print(output)


input()
array = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))

def total(array, A, B):
	total = 0
	for number in array:
		if number in A:
			total += 1
		if number in B:
			total -= 1
	return total
print(total(array, A, B))


input()
Arr = list(map(int, input().split()))
Good = list(map(int, input().split()))
Bad = list(map(int, input().split()))
D = dict()
for ele in Arr:
	if ele in D:
		D[ele] += 1
	else:
		D[ele] = 1
score = 0
for ele in Good:
	if ele in D:
		score += D[ele]
for ele in Bad:
	if ele in D:
		score -= D[ele]
print(score)


(N, M) = map(int, input().strip().split(' '))
ar = list(map(int, input().strip().split(' ')))
A = set(map(int, input().strip().split(' ')))
B = set(map(int, input().strip().split(' ')))
happiness = 0
for x in ar:
	if x in A:
		happiness += 1
	elif x in B:
		happiness -= 1
print(happiness)


(_, _) = tuple(map(int, input().split()))
ar_n = tuple(map(int, input().split()))
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
happiness = 0
from collections import Counter
count_total = Counter(ar_n)
count_happy = Counter(a)
count_sad = Counter(b)
for char in count_total:
	if char in count_happy:
		happiness += count_total[char] * count_happy[char]
	elif char in count_sad:
		happiness -= count_total[char] * count_sad[char]
print(happiness)


from collections import Counter
input()
array = input().strip().split()
A = input().strip().split()
B = input().strip().split()
c = Counter(array)
cs = set(c)
sa = set(A)
sb = set(B)
pos = cs & sa
neg = cs & sb
score = 0
for s in pos:
	score += c[s]
for s in neg:
	score -= c[s]
print(score)


def countOccurences(theList, compareWithSet):
	count = 0
	for i in theList:
		if compareWithSet.__contains__(i):
			count += 1
	return count
inputNumbers = input().split()
n = int(inputNumbers[0])
m = int(inputNumbers[1])
myArray = [int(i) for i in input().split()]
aList = [int(i) for i in input().split()]
bList = [int(i) for i in input().split()]
aSet = set(aList)
bSet = set(bList)
countInASet = countOccurences(myArray, aSet)
countInBSet = countOccurences(myArray, bSet)
happiness = countInASet - countInBSet
print(happiness)


def get_input():
	(n, m) = map(int, input().split())
	array = (int(i) for i in input().split())
	A = set(map(int, input().split()))
	B = set(map(int, input().split()))
	return (array, A, B)

def gen_happiness(args):
	(array, A, B) = args
	happiness = 0
	for integer in array:
		if integer in A:
			happiness += 1
		elif integer in B:
			happiness -= 1
	return happiness
_i = get_input()
happiness = gen_happiness(_i)
print(happiness)


(m, n) = tuple(map(int, input().split()))
arr = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
happy = len([x for x in arr if x in A])
sad = len([i for i in arr if i in B])
print(happy - sad)


inp = input().split()
n = int(inp[0])
m = int(inp[1])
arr = input().split()
a = set(input().split())
b = set(input().split())
happiness = 0
for i in arr:
	if i in a:
		happiness += 1
	elif i in b:
		happiness -= 1
print(happiness)


from collections import Counter
(n, m) = map(int, input().split())
t = list(map(int, input().split()))
c = Counter(t)
A = set(map(int, input().split()))
B = set(map(int, input().split()))
sc = set(c)
inter_a = sc & A
inter_b = sc & B
h = 0
for e in inter_a:
	h += c[e]
for e in inter_b:
	h -= c[e]
print(h)


from collections import defaultdict
(n, m) = map(int, input().split())
array = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
h = 0
d = defaultdict(list)
for i in range(n):
	d[array[i]].append(i)
for i in range(m):
	if d[a[i]] != []:
		h += len(d[a[i]])
	if d[b[i]] != []:
		h += -len(d[b[i]])
print(h)


(n, m) = (int(x) for x in input().split())
v = [int(x) for x in input().split()]
a = {int(x) for x in input().split()}
b = {int(x) for x in input().split()}
count = 0
for num in v:
	if num in a:
		count += 1
	elif num in b:
		count -= 1
print(count)


(n, m) = list(map(int, input().split()))
nums = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
hapiness = 0
for i in nums:
	if i in A:
		hapiness += 1
	elif i in B:
		hapiness -= 1
print(hapiness)


(n, m) = map(int, input().split())
numbers = map(int, input().split())
a = set(map(int, input().split()))
b = set(map(int, input().split()))
happiness = 0
for number in numbers:
	if number in a:
		happiness += 1
	if number in b:
		happiness -= 1
print(happiness)


(n, m) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
A = set(list(map(int, input().strip().split())))
B = set(list(map(int, input().strip().split())))
happy = 0
for i in a:
	if i in A:
		happy += 1
	if i in B:
		happy -= 1
print(happy)


from collections import Counter
(n, m) = tuple(input().strip().split(' '))
n_array = Counter(list(map(int, input().strip().split(' '))))
a_array = list(map(int, input().strip().split(' ')))
b_array = list(map(int, input().strip().split(' ')))
result = 0
for itr in a_array:
	result += n_array[itr]
for itr in b_array:
	result -= n_array[itr]
print(result)


(n, m) = map(int, input().split())
arr = input().split()
A = set(input().split())
B = set(input().split())
happiness = 0
for i in arr:
	if i in A:
		happiness += 1
	if i in B:
		happiness -= 1
print(happiness)


(n, m) = map(int, input().split(' '))
array = input().split(' ')
if len(array) != n:
	del array[-1]
array = tuple(map(int, array))
a = input().split(' ')
if len(a) != m:
	del a[-1]
a = set(map(int, a))
b = input().split(' ')
if len(b) != m:
	del b[-1]
b = set(map(int, b))
happiness = 0
for number in array:
	if number in a:
		happiness += 1
	elif number in b:
		happiness -= 1
print(happiness)


(n, m) = [int(__) for __ in input().split()]
nlist = [int(__) for __ in input().split()]
A = set([int(__) for __ in input().split()])
B = set([int(__) for __ in input().split()])
good = [__ for __ in nlist if __ in A]
bad = [__ for __ in nlist if __ in B]
print(len(good) - len(bad))


(n, m) = input().split()
(n, m) = (int(n), int(m))
list_integer = input().split()
list_integer = list(map(int, list_integer))
list_a = input().split()
list_b = input().split()
set_a = set(list(map(int, list_a)))
set_b = set(list(map(int, list_b)))
happiness = 0
list_a = list(set_a)
list_b = list(set_b)
for iterator in list_integer:
	if iterator in set_a:
		happiness += 1
	if iterator in set_b:
		happiness -= 1
print(happiness)


(n, m) = input().strip().split()
ls = list(map(int, input().strip().split()))
A = set(map(int, input().strip().split()))
B = set(map(int, input().strip().split()))
happiness = 0
for x in ls:
	if x in A:
		happiness += 1
	elif x in B:
		happiness -= 1
print(happiness)


(n, m) = input().split()
arr = input().split()
pos = set(input().split())
neg = set(input().split())
count = 0
for a in arr:
	if a in pos:
		count += 1
	if a in neg:
		count -= 1
print(count)


(n, m) = map(int, input().split())
S = list(map(int, input().split()))
A = set(map(int, input().split()))
B = set(map(int, input().split()))
print(len(list(filter(lambda x: x in A, S))) - len(list(filter(lambda x: x in B, S))))


from collections import Counter
line = input().split()
n = int(line[0])
m = int(line[1])
N = []
line = input().split()
for i in range(0, n):
	N.append(int(line[i]))
A = input().split()
A = [int(x) for x in A]
B = input().split()
B = [int(x) for x in B]
happy = 0
c = Counter(N)
for i in range(0, m):
	happy += c[A[i]]
for i in range(0, m):
	happy -= c[B[i]]
print(happy)


from collections import Counter
n_m = list(map(int, input().split(' ')))
array = list(map(int, input().rstrip().split(' ')))
a = Counter(list(map(int, input().rstrip().split(' '))))
b = Counter(list(map(int, input().rstrip().split(' '))))
happy = 0
for x in array:
	happy += a[x] * 1
	happy += b[x] * -1
print(happy)


(n, m) = list(map(int, input().split()))
ns = list(map(int, input().split()))
h = set(map(int, input().split()))
s = set(map(int, input().split()))
happy = 0
for x in ns:
	if x in h:
		happy += 1
	elif x in s:
		happy -= 1
print(happy)


import sys
from collections import Counter as mset
args = [line.strip() for line in sys.stdin]
array = [int(i) for i in args[1].split()]
A = [int(i) for i in args[2].split()]
B = [int(i) for i in args[3].split()]

def intersect(L):
	L1 = mset(L) | mset(array)
	L2 = mset(L) + mset(set(array).intersection(set(L)))
	L3 = L2 - L1
	L4 = mset(set(L).intersection(set(array))) - L3
	L5 = mset(array) - mset(set(array)) + L4
	while len(L5) > len(L4):
		L5 = L5 - mset(set(array)) + L4
	return L5 | L3
L = sum(intersect(A).values())
D = sum(intersect(B).values())
print(L - D)


from collections import Counter
(n_val, m_val) = list(map(int, input().split(' ')))
arr = Counter(input().rstrip().split(' '))
a_arr = input().rstrip().split(' ')
b_arr = input().rstrip().split(' ')
happiness = 0
for a in a_arr:
	happiness += arr[a]
for b in b_arr:
	happiness -= arr[b]
print(happiness)


(array_length, set_length) = map(int, input().split())
array = list(map(int, input().split()))
a_set = set(map(int, input().split()))
b_set = set(map(int, input().split()))
print(sum(((val in a_set) - (val in b_set) for val in array)))