Problem:
Search I You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S. Input In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given. Output Print C in a line. Constraints  n ≤ 10000  q ≤ 500  0 ≤ an element in S ≤ 10 9  0 ≤ an element in T ≤ 10 9  Sample Input 1 5
1 2 3 4 5
3
3 4 1 Sample Output 1 3 Sample Input 2 3
3 1 2
1
5 Sample Output 2 0 Sample Input 3 5
1 1 2 2 3
2
1 2 Sample Output 3 2 Notes

Solution (Python):
def liner_search(r,key):
    for x in r:
        if x == key:
            return True
    return False


N = int(input())
S = list(map(int, input().split()))
q = int(input())
Key = list(map(int, input().split()))
cnt = 0
for i in range(q):
    if liner_search(S, Key[i]):
        cnt += 1

print(cnt)

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

C = []
for s in S:
  for t in T:
    if s == t and not s in C: C.append(s)
print(len(C))

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

C = 0
for t in T:
  for s in S:
    if s == t:
      C += 1
      break
print(C)

Solution (Python):

n = int(input())
S = {int(s) for s in input().split()}

q = int(input())
T = {int(t) for t in input().split()}

cnt = sum(t in S for t in T)

print(cnt)

Solution (Python):

def LinearSearch(n, S, t):
    """ ????????????????????¢????????? """
    S.append(t)
    i = 0

    while S[i] != t:
        i += 1

    if i == n:
        return -1
    else:
        return i

n = int(input())
S = [int(s) for s in input().split()]

q = int(input())
T = [int(t) for t in input().split()]

cnt = 0

for t in T:
    if LinearSearch(n, S[:], t) != -1:
        cnt += 1

print(cnt)

Solution (Python):

def LinearSearch1(S, n, t):
    for i in range(n):
        if S[i] == t:
            return i
            break
    else:
        return -1

"""
def LinearSearch2(S, n, t):
    S.append(t)
    i = 0

    while S[i] != t:
        i += 1

    S.pop()
    if i == n:
        return -1
    else:
        return i
"""

n = int(input())
S = [int(s) for s in input().split()]

q = int(input())
T = {int(t) for t in input().split()}

ans = sum(LinearSearch1(S, n, t) >= 0 for t in T)

print(ans)

Solution (Python):
"""
def LinearSearch1(S, n, t):
    for i in range(n):
        if S[i] == t:
            return i
            break
    else:
        return -1
"""

def LinearSearch2(S, n, t):
    S.append(t)
    i = 0

    while S[i] != t:
        i += 1

    S.pop()
    if i == n:
        return -1
    else:
        return i


n = int(input())
S = [int(s) for s in input().split()]

q = int(input())
T = {int(t) for t in input().split()}


ans = sum(LinearSearch2(S, n, t) >= 0 for t in T)

print(ans)

Solution (Python):
def linear_search(A, n, key):
    A.append(key)
    i = 0
    while A[i] != key:
        i += 1
    A.pop()
    return i != n

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
count = 0
for i in T:
    if linear_search(S, n, i):
        count += 1


print(count)

Solution (Python):
def main():
    input()
    a = set(input().split())
    input()
    b = set(input().split())
    print(len(a.intersection(b)))


if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Solution (Python):
input()
s = set(map(int,input().split()))
n = int(input())
t = tuple(map(int,input().split()))
c = 0
for i in range(n):
    if t[i] in s:
        c += 1
print(c)

Solution (Python):
def linearSearch(n, S, q, T):
    count = 0
    if n <= q:
        for i in S:
            if i in T:
                count += 1
        print(count)
                
    else:
        for k in T:
            if k in S:
                count += 1
        print(count)
                
    

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

linearSearch(n, S, q, T)

Solution (Python):
input()
a=input().split()
input()
print(len(set(a)&set(input().split())))

Solution (Python):
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

S.append(-1)
sum = 0
for i in T:
    count = 0
    while True:
        if i != S[count]:
            count += 1
        else:
            sum += 1
            break
        if S[count] == -1:
            break
print(sum)

Solution (Python):
import sys


fin = sys.stdin

n = int(fin.readline())
S = list(map(int, fin.readline().split()))
q = int(fin.readline())
T = list(map(int, fin.readline().split()))

ret = 0

for t in T:
	for s in S:
		if t == s:
			ret += 1
			break

print(ret)

Solution (Python):
n = input()
S = list(map(int,input().split()))
n = input()
T = list(map(int,input().split()))
count =  0
for i in T:
    if i in S:
        count+= 1
print(count)

Solution (Python):
n = int(input())
s = input().split()
n = int(input())
t = input().split()
count = 0
for a in t:
    if a in s:
        count += 1
        
print(count)

Solution (Python):
n = raw_input()                                                
l = map(int, raw_input().split())                              
n = raw_input()                                                
                                                               
sum = 0                                                        
for i in map(int, raw_input().split()):                        
    if i in l:                                                 
        sum += 1                                               
                                                               
print sum

Solution (Python):



def main():
    s_length = int(raw_input())
    s = [int(x) for x in raw_input().strip().split(' ')]
    t_length = int(raw_input())
    t = [int(x) for x in raw_input().strip().split(' ')]

    counter = 0
    for value in t:
        if value in s:
            counter += 1

    print counter 

if __name__ == '__main__':
    main()

Solution (Python):



def main():
    s_length = raw_input()
    s = set(raw_input().strip().split(' '))
    t_length = raw_input()
    t = set(raw_input().strip().split(' '))

    print len(s.intersection(t))

if __name__ == '__main__':
    main()

Solution (Python):



def main():
    s_length = raw_input()
    s = set(raw_input().strip().split(' '))
    t_length = raw_input()
    t = set(raw_input().strip().split(' '))

    print len(s.intersection(t))

if __name__ == '__main__':
    main()

Solution (Python):



def main():
    s_length = raw_input()
    s = set(raw_input().strip().split(' '))
    t_length = raw_input()
    t = set(raw_input().strip().split(' '))

    print len(s & t)

if __name__ == '__main__':
    main()

Solution (Python):

def linear_search(value, target_list):
    for key in target_list:
        if value == key:
            return True
    return False


def main():
    s_length = raw_input()
    s = raw_input().strip().split(' ')
    t_length = raw_input()
    t = raw_input().strip().split(' ')


    counter = 0
    for t_value in t:
        counter += int(linear_search(t_value, s))

    print counter

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]
C = 0
for i in T:
    for j in S:
        if j == i:
            C += 1
            break
print(C)

Solution (Python):
n = list(input())
sList = list(map(int,input().split()))

q = list(input())
tList = list(map(int,input().split()))

tCount = 0


for tmp_t in tList:
    if 0 < sList.count(tmp_t):
        tCount += 1

print(tCount)

Solution (Python):
n = int(input())
s = input().split()
q = int(input())
t = input().split()
cont = 0
for i in t:
    for o in s:
        if i == o:
            cont +=1
            break

print(cont)

Solution (Python):
n = int(input())
s = set(input().split())
q = int(input())
t = set(input().split())

print(len(s & t))

Solution (Python):
def linearSearch(A, n, key):
	i = 0
	A.append(key)
	while (A[i] != key):
		i += 1
	del A[n]

	return i != n


if __name__ == '__main__':
	
	n = int(input())
	L = list(map(int, input().split()))

	q = int(input())
	Key = list(map(int, input().split()))

	cnt = 0
	for i in range(q):
		if (linearSearch(L, n, Key[i])):
			cnt += 1

	print(cnt)

Solution (Python):
def linearSearch(A, n, key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    del A[n]
    return i != n


if __name__ == '__main__':
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))
    cnt = 0

    for i in range(q):
        if linearSearch(S, n,T[i]):
            cnt += 1

    print(cnt)

Solution (Python):
while True:
    try:
        n = int(input())
        S = list(map(int, input().split()))
        _ = int(input())
        print(sum([1 for t in list(map(int, input().split())) if t in S]))
    except:break

Solution (Python):
N = int(input())
S = list(map(int, input().split()))
Q = int(input())
T = list(map(int, input().split()))

S = set(S)
T = set(T)
C = list(S & T)
print(len(C))

Solution (Python):
S_num = int(input())
seq_S = set(input().split(" "))
T_num = int(input())
seq_T = set(input().split(" "))

seq_Both = seq_S & seq_T

print(len(seq_Both))

Solution (Python):


_ = int(input())
ns = [int(e) for e in input().split()]
_ = int(input())
qs = [int(e) for e in input().split()]


def main(ns, qs):
    total = 0
    for q in qs:
        if q in ns:
            total += 1
    return total


print(main(ns, qs))

Solution (Python):
n=int(input())
S=list(map(int,input().split()))

q=int(input())
T=list(map(int,input().split()))
c=0
for i in T:
    for j in S:
        if i==j:
            c+=1
            break
print(c)

Solution (Python):
n = input()
S = input().split()
q = input()
T = input().split()
cnt = 0

for i in range(len(T)):
    if T[i] in S:
        cnt += 1

print(cnt)

Solution (Python):
n = int(input())
S = [int(x) for x in input().split()]
q = int(input())
T = [int(x) for x in input().split()]


res = 0

for num in T:
    if num in S:
        res += 1

print(res)

Solution (Python):


import sys
import os


n = int(input())
S = list(map(int, input().split()))

q = int(input())
T = list(map(int, input().split()))

count = 0
for query in T:
    if query in S:
        count += 1
print(count)

Solution (Python):
c = 0
input()
s = input().split()
input()
t = input().split()
for make in t :
    if make in s : c += 1
print(c)

Solution (Python):

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

findCount = 0

for t in T:
    for s in S:
        if t == s:
            findCount += 1
            break

print(findCount)

Solution (Python):
n = int(input())
s_list = list(map(int, input().split()))
q = int(input())
t_list = list(map(int, input().split()))

c = 0
for t in t_list:
    if t in s_list:
        c += 1

print(c)

Solution (Python):
a_len = int(input())
a = {n for n in input().split(" ")}
b_len = int(input())
b = {n for n in input().split(" ")}
print(len(a & b))

Solution (Python):
n = int(input())
s = list(set(map(int, input().split())))
q = int(input())
t = list(map(int, input().split()))
cnt = 0

for i in range(len(s)):
    for j in range(q):
        if s[i] == t[j]:
            cnt += 1

print(cnt)

Solution (Python):
def main():
    n = input()
    S = map(int,raw_input().split())
    q = input()
    T = map(int,raw_input().split())
    m = 0
    for i in range(q):
        t = T.pop()
        for j in range(n):
            s = S[j]
            if t == s:
                m += 1
                break
                
    print m

if __name__ == "__main__":
    main()

Solution (Python):
def linear_search():
	input()
	s = set(input().split())
	input()
	t = set(input().split())
	print(len(s & t))	

if __name__ == '__main__':
	linear_search()

Solution (Python):
n = int(input())
S = input().split()
q = int(input())
T = input().split()
cnt = 0
for i in range(q):
    if T[i] in S:
        cnt += 1
print(cnt)

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
cnt = 0
for i in T:
 for j in S:
  if i == j:
   cnt += 1
   break

print(str(cnt))

Solution (Python):


n = int(input())
S = list(map(int, input().split()))
q = int(input())
counter = 0

for t in map(int, input().split()):
    if t in S:
        counter += 1

print(counter)

Solution (Python):



n = int(input())
S = list(map(int, input().split(" ")))
q = int(input())
T = list(map(int, input().split(" ")))

num = 0
for t in T:
    if t in S:
        num += 1
print(num)

Solution (Python):
len_s = int(input())
s = [int(i) for i in input().split()]
len_t = int(input())
t = [int(i) for i in input().split()]
cnt = 0

for f in t:
    i = 0
    while i < len(s) and s[i] != f:
        i += 1
    if i < len(s):
        cnt +=1
print(cnt)

Solution (Python):
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = tuple(map(int, input().split()))

cnt = 0
for n in T:
    cnt += n in S

print(cnt)

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))
    ans = 0
    for i in T:
        if i in S:
            ans += 1
    print(ans)

Solution (Python):
n = int(input())
s = input().split(" ")
S = list(map(int,s))
q = int(input())
t = input().split(" ")
T = list(map(int,t))
C = []
for i in range(n):
    flag = 0
    for k in range(len(C)):
        if S[i] == C[k]:
            flag = 1
            break
    if flag == 1:
        continue
    for j in range(q):
        if S[i] == T[j]:
            C.append(S[i])
            break
print(len(C))

Solution (Python):
n = int(input())
S = list(map(int, input().split(" ")))
q = int(input())
T = list(map(int, input().split(" ")))

C = 0
for t in T:
    if t in S:
        C += 1
print(C)

Solution (Python):
n1 = int(input())
s = (input()).split()
n2 = int(input())
t = (input()).split()
m = []

for i in range(0, n2):
      key = t[i]
      for j in range(0, n1):
            if s[j] == t[i]:
                  m.append(s[j])
                  break
print(len(m))

Solution (Python):
n = int(input())
S = input().split()
q = int(input())
T = input().split()
cnt = 0
for i in range(q):
    if T[i] in S:
        cnt += 1
print(cnt)

Solution (Python):
n=input()
S=input().split()
q=input()
T=input().split()
c=0
for t in T:
    if(t in S):c+=1
print(c)

Solution (Python):
n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]
cnt = 0
for T in T:
    if T in S:
        cnt += 1
print(cnt)

Solution (Python):
def main():
	num = 0

	_ = input()
	s_set = set(map(int, input().split()))

	_ = input()
	t_set = set(map(int, input().split()))
	for t in t_set:
		if t in s_set:
			num +=1
	
	print(num)

if __name__ == '__main__':
	main()

Solution (Python):
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]

cnt = 0

for x in t:
	if x in s:
		cnt += 1

print(cnt)

Solution (Python):
n = int(input())
S = [int(s) for s in input().split()]
q = int(input())
T = [int(s) for s in input().split()]

print(sum([t in S for t in T]))

Solution (Python):


"""
Linear Search
n ????????´??°???????????°??? S ??¨???q ????????°????????´??°???????????°??? T ??????????????????
T ?????????????????´??°????????§ S ?????????????????????????????° C ???????????????????????°????????????????????????????????????
"""

def main():
    """ ????????? """
    n = int(input())
    S = list(input().split())
    q = int(input())
    T = list(input().split())

    cnt = {}
    for i in range(n):
        for j in range(q):
            if S[i] == T[j]:
                cnt[T[j]] = 1
                break
    print(len(cnt))


if __name__ == '__main__':
    main()

Solution (Python):
def linearSearch(t):
    i=0
    s=S[:]+[t]
    while s[i]!=t:
        i+=1
    if i==n:
        return 0
    return 1

n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

C=0

for t in T:
    C+=linearSearch(t)
    
print(C)

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

cnt = 0
for t in T:
    if t in S:
        cnt += 1
print(cnt)

Solution (Python):
input()
S = set(input().split())
input()
T = set(input().split())
print(len(S & T))

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = map(int, input().split())

def ls(A, k):
    for a in A:
        if k == a:
            return True
    return False

print(sum([ls(S, t) for t in T]))

Solution (Python):
n = int(raw_input())
if n > 1:
    s = map(int, raw_input().split())
else:
    s = int(raw_input())
    
q = int(raw_input())
if q > 1:
    t = map(int, raw_input().split())
else:
    t = int(raw_input())

count = 0
for i in range(q):
    try:
        a = s.index(t[i])
        count += 1
    except:
        pass

print count

Solution (Python):
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

sum = 0

for i in T:
    if i in S:
        sum +=1
        
print(sum)

Solution (Python):


n=int(input())
S=[int(i) for i in input().split()]
q=int(input())
T=[int(i) for i in input().split()]
c=0
for i in range(q):
    j=0
    while j<n and T[i]!=S[j]:
        j+=1
    if j<n:
        c+=1
print(c)

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


_ = input()
S = set([int(_) for _ in input().split()])
_ = input()
T = set([int(_) for _ in input().split()])
print(len(S.intersection(T)))

Solution (Python):
import sys

n = int(sys.stdin.readline().strip())
S = map(int, sys.stdin.readline().strip().split(" "))

n = int(sys.stdin.readline().strip())
T = map(int, sys.stdin.readline().strip().split(" "))

res = []

for t in T:
    res.append(int(S.count(t) != 0))
print sum(res)

Solution (Python):
N = int(input())
S = list(map(int, input().split()))
Q = int(input())
T = list(map(int, input().split()))

cnt = 0
for i in T:
    for j in S:
        if i == j:
            cnt += 1
            break
print(cnt)

Solution (Python):
n = int(input())
S = set([int(i) for i in input().split()])
q = int(input())
T = set([int(i) for i in input().split()])
print(len( S & T ))

Solution (Python):
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = set(map(int, input().split()))

count = 0
for x in T:
    count += 1 if x in S else 0

print(count)

Solution (Python):
n = int(raw_input())
S = map(int, raw_input().split())

q = int(raw_input())
T = map(int, raw_input().split())

ans = 0

for i in T:
    if i in S:
        ans += 1

print ans

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

ans = sum([1 for tmp_t in T if tmp_t in S])

print(ans)

Solution (Python):
n = input()
s = list(map(int, input().split()))
nn = input()
t = list(map(int, input().split()))
t_and_s = len(set(s) & set(t))
print(t_and_s)

Solution (Python):
n = int(input())
S = map(int,raw_input().split())
q = int(input())
T = map(int,raw_input().split())
count = 0
for v in T:
    for i in range(n):
        if S[i] == v:
            count += 1
            break
print count

Solution (Python):
n = int(input())
S = [int(i) for i in input().split()] + [0]
q = int(input())
T = [int(i) for i in input().split()]
c = 0

for i in T:
    S[n] = i
    j = 0
    while i != S[j]:
        j += 1
    if j != n:
        c += 1

print(c)

Solution (Python):
n = int(input())
s = set(map(int,input().split()))
q = int(input())
t = set(map(int,input().split()))

print(len(s & t))

Solution (Python):
n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))
count = 0

for i in range(q):
    if t[i] in s:
        count += 1
print(count)

Solution (Python):
def ALDS1_4A():
    n, S = int(input()), set(map(int, input().split()))
    q, T = int(input()), set(map(int, input().split()))
    print(len(S.intersection(T)))
if __name__ == '__main__':
    ALDS1_4A()

Solution (Python):
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

count = 0
for item in t:
    if item in s:
        count += 1
print(count)

Solution (Python):

import sys


def liner_search(data, targets):
    cnt = 0
    for num in targets:
        if num in data:
            cnt += 1
    return cnt


if __name__ == "__main__":
    data = [val.split() for val in sys.stdin.read().splitlines()]
    print(liner_search(data[1], data[3]))

Solution (Python):
def linearSearch(S, T):
    cnt = 0
    for e in T:
        if e in S:
            cnt += 1
    return cnt


def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    print(linearSearch(s, t))

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
cnt = 0

for i in T:
    if i in S:
        cnt += 1
print(cnt)

Solution (Python):
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = set(map(int, input().split()))
print(len(S & T))

Solution (Python):
n = raw_input()
S = map(int, raw_input().split())
q = raw_input()
T = map(int, raw_input().split())

cnt = 0
for i in T:
	if i in S:
		cnt += 1

print cnt

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = map(int, input().split())

count = 0
for key in T:
    U = S + [key]
    i = 0
    while U[i] != key:
        i = i+1
    if i != n:
        count = count + 1
print(count)

Solution (Python):
n = int(input())
S = list(input().split())
q = input()
T = input().split()

count = 0
for key in T:
    U = S + [key]
    i = 0
    while U[i] != key:
        i = i+1
    if i != n:
        count = count + 1
print(count)

Solution (Python):
n = int(input())
S = list(input().split())
q = input()
T = input().split()

count = 0
for key in T:
    U = S + [key]
    i = 0
    while U[i] != key:
        i = i+1
    if i != n:
        count = count + 1
print(count)

Solution (Python):
n = int(input())
S = list(map(int, input(). split()))
q = int(input())
T = list(map(int, input(). split()))

Sum = 0
for i in T:
  if i in S:
    Sum += 1
print(Sum)

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

Sum = 0

for i in T:
  if i in S:
    Sum += 1
print(Sum)

Solution (Python):
def main():
    N = int(input())
    S = set(map(int, input().split()))
    Q = int(input())
    T = set(map(int, input().split()))

    cnt = 0
    for i in T:
        if i in S:
            cnt += 1

    print(cnt)

main()

Solution (Python):
import sys

ERROR_INPUT = 'input is invalid'
ERROR_INPUT_NOT_UNIQUE = 'input is not unique'


def main():
    S = get_input1()
    T = get_input2()

    count = 0
    for t in T:
        for s in S:
            if t == s:
                count += 1
                break

    print(count)


def get_input1():
    n = int(input())
    if n > 10000:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split(' '):
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        li.append(x)

    return li


def get_input2():
    n = int(input())
    if n > 500:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split(' '):
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        elif int(x) in li:
            print(ERROR_INPUT_NOT_UNIQUE)
            sys.exit(1)
        li.append(x)

    return li


main()

Solution (Python):
import sys

ERROR_INPUT = 'input is invalid'
ERROR_INPUT_NOT_UNIQUE = 'input is not unique'


def main():
    S = get_input1()
    T = get_input2()

    count = 0
    for t in T:
        if t in S:
            count += 1

    print(count)


def get_input1():
    n = int(input())
    if n > 10000:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split(' '):
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        li.append(x)

    return li


def get_input2():
    n = int(input())
    if n > 500:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split(' '):
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        elif int(x) in li:
            print(ERROR_INPUT_NOT_UNIQUE)
            sys.exit(1)
        li.append(x)

    return li


main()

Solution (Python):
import sys

ERROR_INPUT = 'input is invalid'
ERROR_INPUT_NOT_UNIQUE = 'input is not unique'


def main():
    S = get_input1()
    T = get_input2()

    count = 0
    for t in T:
        if linner_search(S, t):
            count += 1

    print(count)


def linner_search(li, key):
    li.append(key)
    i = 0
    while li[i] != key:
        i += 1

    return i != len(li) - 1


def get_input1():
    n = int(input())
    if n > 10000:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split(' '):
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        li.append(x)

    return li


def get_input2():
    n = int(input())
    if n > 500:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split(' '):
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        elif int(x) in li:
            print(ERROR_INPUT_NOT_UNIQUE)
            sys.exit(1)
        li.append(x)

    return li


main()

Solution (Python):
def search(S, n, t):
    i=0
    S[n]=t
    while (S[i] != t):
        i+=1
    return i!=n

sum=0

n=int(input())
S=list(map(int, input().split()))

S.append([0]*10000)

q=int(input())
T=list(map(int, input().split()))

for i in range(0,q):
    if search(S,n,T[i]):
        sum+=1

print(sum)

Solution (Python):
input()
l = [int(i) for i in input().split()]
input()
c = 0
for i in input().split():
    for j in l:
        if int(i) == j:
            c += 1
            break
print(c)

Solution (Python):
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = set(map(int, input().split()))
print(len(S & T))

Solution (Python):



def linearSearch(l, key):
    m = len(l)
    l.append(key)
    i = 0
    while l[i] != key:
        i += 1
    l.pop()
    if i == m:
        return "NOT_FOUND"
    return i


if __name__ == '__main__':

    n = int(input())
    S = [int(s) for s in input().split(" ")]
    q = int(input())
    T = [int(t) for t in input().split(" ")]

    count = 0
    for t in T:
        if linearSearch(S, t) != "NOT_FOUND":
            count += 1

    print(count)

Solution (Python):
n=int(input())
S=input().split(' ')
q=int(input())
T=input().split(' ')

def equal_element(S,T):
	m=0
	for i in range(len(T)):
		for j in range(len(S)):
			if S[j]==T[i]:
				m+=1
				break
	return(m)
	
print(equal_element(S,T))

Solution (Python):
first_set_count = int(input());
first_set = [int(n) for n in input().split()];
second_set_count = int(input());
second_set = [int(n) for n in input().split()];

def linear_search(first_set, second_set):
    count = 0;
    for n in second_set:
        for m in first_set:
            if n == m:
                count += 1;
                break;
    print(count);

linear_search(first_set, second_set);

Solution (Python):
def linearSearch(S, N, key):
    i = 0
    S[N] = key
    while S[i] != key:
        i += 1
    if i != N:
        return True
    
N = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))  

S.append(0)

sum = 0 

for j in range(q):
    if linearSearch(S,N,T[j]) == True:
        sum += 1
    
print(sum)

Solution (Python):
def linearSearch(A, key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    if i == len(A)-1:
        A.pop()
        return 'Not_found'
    A.pop()
    return i

if __name__ == '__main__':
    c = 0
    n = int(input())
    hoge1 = [int(x) for x in input().split()]
    q = int(input())
    for key in (int(x) for x in input().split()):
        if linearSearch(hoge1, key) == 'Not_found':
            continue
        else:
            c += 1
    print (c)

Solution (Python):
n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]
cnt = 0
for i in t:
    if i in s:
        cnt+=1
print(cnt)

Solution (Python):
input()
s=set(input().split())
print(int(input())-len(set(input().split())-s))

Solution (Python):
input()
s=set(input().split())
input()
print(len(s&set(input().split())))

Solution (Python):
import sys
s=sys.stdin.readlines()
print(len(set(s[1].split())&set(s[3].split())))

Solution (Python):

n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
ans = 0
for v in T:
  if v in S:
    ans += 1
print(ans)

Solution (Python):

n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
ans = 0
def linsearch(v,S):
  for w in S:
    if v == w:
      return True
  return False
  
for v in T:
  if linsearch(v,S):
    ans += 1
  
print(ans)

Solution (Python):



import sys

n = int(sys.stdin.readline())
s = list(map(int, sys.stdin.readline().split()))
q = int(sys.stdin.readline())
t = list(map(int, sys.stdin.readline().split()))

s_set = set(s)
total = 0

for x in t:
    if x in s_set:
        total += 1

print(total)

Solution (Python):
n = int(input())
s = list(map(int, input().split()))

q = int(input())
t = list(map(int, input().split()))

count = 0

for i in range(q):
    s.append(t[i])
    j = 0
    while t[i] != s[j]:
        j += 1
    if j != n:
        count += 1
    del s[n]
print(count)

Solution (Python):
n =int(input())

S = list(map(int, input().split(' ')))

q = int(input())

T = list(map(int, input().split(' ')))

count = 0
for t in T:
    if t in S:
        count += 1
print(count)

Solution (Python):
input()
s = list(map(int, input().split()))
input()
t = list(map(int, input().split()))

cnt = 0
for i in t:
    if i in s:
        cnt += 1
print(cnt)

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

Sset = set(S)
Tset = set(T)

print(len(Sset & Tset))

Solution (Python):
import sys

def linierSearch(x,data):
    for i in range(0,len(data)):
        if data[i] == x:
            return 1
    return 0

l = []
for i in sys.stdin:
    l.append(i)

l[1] = l[1].split()
l[3] = l[3].split()

count = 0
for i in range(0,len(l[3])):
    count += linierSearch(l[3][i],l[1])

print(count)

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
ans = 0
for i in T:
    if i in S:
        ans += 1
print(ans)