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 count(xs, ys):
    """Returns a count of elements in xs which is also in ys.

    >>> count([1, 2, 3], [1, 3])
    2
    >>> count([1, 2, 3, 4, 5], [3, 4, 1])
    3
    """
    xset = set(xs)
    yset = set(ys)
    return len(xset & yset)


def run():
    _ = input()  
    s = [int(i) for i in input().split()]
    _ = input()  
    t = [int(j) for j in input().split()]

    print(count(s, t))


if __name__ == '__main__':
    run()

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

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

count = 0

for i in t:
    
    s += [i]
    j = 0
    while s[j] != i:
        j += 1
    s.pop()
    if j == ns:
        continue
    count += 1

print(count)

Solution (Python):
input()
a = set(map(int, input().split()))
input()
b = set(map(int, input().split()))
print(len(a & b))

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 i in t:
    if i in s:
        cnt += 1
print(cnt)

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

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

print(res)

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 range(q):
    if T[i] in S:
        ans += 1
print(ans)

Solution (Python):
n = int(input())
s = input().split()
m = int(input())
t = input().split()
c = 0
for i in t:
    if i 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(' ')]

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

print(result)

Solution (Python):

"""
Created on Mon Apr 30 11:23:30 2018
ALDS1-4a most simple implementation using the features of the python
@author: maezawa
"""

n = int(input())
s = map(int, input().split())
q = int(input())
t = map(int, input().split())

s_set = set(s)
t_set = set(t)
sandt = s_set & t_set
print(len(sandt))

Solution (Python):

"""
Created on Mon Apr 30 11:33:59 2018
ALDS1-4a_r  simple implementation without sets
@author: maezawa
"""

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

cnt = 0

for i in t:
    if 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(' ')]

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

print(c)

Solution (Python):
n = int(input())
a = set(input().split())
m = int(input())
b = set(input().split())
print(len(a&b))

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

S_s =set(S)
T_s =set(T)
C = S_s & T_s
print(len(C))

Solution (Python):
S=[]
T=[]

S_num=int(input())
S=input().split()

T_num=int(input())
T=input().split()

cnt=0
for i in range(T_num):
	for j in range(S_num):
		if(S[j]==T[i]):
			cnt+=1
			break

print(cnt)

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

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

for i in t:
    for j in s:
        if i == j:
            c += 1
            break
print(c)

Solution (Python):
n1=int(input())
l1=list(input().split())

n2=int(input())
l2=list(input().split())


cnt=0
for x in l2:
    if x in l1:
        cnt=cnt+1


print(cnt)

Solution (Python):

S=int(input())
A=list(input().split())

T=int(input())
B=list(input().split())

n=0

for i in B:
    if i in A:
        n=n+1

print(n)

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

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

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

S=[0 for i in range(sn)]

S=input().split()

tn = int(input())

T=[0 for i in range(tn)]

T=input().split()

cnt=0

A=[]

for i in range(len(T)):
	for j in range(len(S)):
		if T[i]==S[j]:
			if T[i] not in A:
				cnt+=1
			A.append(T[i])

print(cnt)

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

n = int(input())
T = list(map(int, input().split()))
cnt = 0

for i in T:
    for j in S:
        if j == i:
            cnt += 1
            break

print(cnt)

Solution (Python):


def set_array(a,n):
	str=input()
	array=str.split()
	for i in range(n):
		a.append(int(array[i]))
	

n=int(input())
S=[]
set_array(S,n)
q=int(input())
T=[]
set_array(T,q)
C=0

def linear_search(S,x):
	S.append(x)
	l=len(S)
	i=0
	while(l>i):
		if S[i]==x:
			break
		i=i+1
	S.pop(-1)
	if i!=l-1:
		return 1;
	else:
		return 0;
for v in T:
	C+=linear_search(S,v)

print(C)

Solution (Python):
def linearSearch(A,key):
    for i in range(len(A)):
        if A[i]==key:
            return i
        else: pass
    return -1


n=int(input())
s=list(input().split())
q=int(input())
t=input().split()

cnt=0
for i in range(q):
    x=linearSearch(s,t[i])
    if x!=(-1):
        cnt+=1
        
print(cnt)

Solution (Python):
def linear_search(arr, key):
    idx = 0
    while arr[idx] != key:
        idx += 1

    if idx == len(arr) - 1:
        return False

    return True


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

s.append(None)
cnt = 0
for i in range(q):
    s[n] = t[i]
    if linear_search(s, t[i]):
        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=int(input())
a=input().split()

m=int(input())
b=input().split()

a=[int(i) for i in a]
b=[int(i) for i in b]

a.sort()
b.sort()
cnt=0

for j in range(m):
  if b[j] in a:
    cnt+=1
print(cnt)

Solution (Python):

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

Solution (Python):
n=int(input())
S=input().split()
q=int(input())
T=input().split()
cnt=0
B=[]
for i in range(len(T)):
    c=0
    for j in range(len(S)):
        if T[i]==S[j]:
            if c==0:
                cnt+=1
                c+=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(t&s))

Solution (Python):
n1=input()
X=set(input().split())
n2=input()
Y=set(input().split())
print(len(X&Y))

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

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

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

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

for i in range(q):
    for j in range(n):
        if(s[j] == r[i]):
            cou += 1
            break
print(cou)

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

Solution (Python):

n=int(input())
lista=[0 for i in range(n)]
lista=input().split()
n2=int(input())
listb=[0 for i in range(n2)]
listb=input().split()
cnt=0
for i in range(n2):
    x=0
    
    for j in range(n):
        if listb[i]==lista[j] and x==0:
            x=1
            cnt+=1

print(cnt)

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

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

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

    cnt = 0
    for et in t:
        sc = s.copy()
        sc.append(et)
        i = 0

        while sc[i] != et:
            i += 1

        if i < n:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
S = list(map(int, input().split(' ')))
q = int(input())
T = list(map(int, input().split(' ')))
counter = 0
for t in  T:
    for s in S:
        if(s == t):
            counter += 1
            break

print(counter)

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

print(cnt)

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

cnt = 0

for t in T:
    if t in S:
        cnt += 1

print(cnt)

Solution (Python):



def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    n = int(input())
    S = intinput()
    q = int(input())
    T = intinput()
    count = 0
    for k in T:
        if k in S: count += 1
    print(count)

    
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 t in T:
    for s in S:
        if t == s:
            cnt += 1
            break

print(cnt)

Solution (Python):

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

def search_banpei(array, target, cnt):
    tmp = array[len(array)-1]
    array[len(array)-1] = target

    n = 0
    while array[n] != target:
        n += 1

    array[len(array)-1] = tmp
    if n < len(array) - 1 or target == tmp:
        cnt += 1
    return cnt        

def linear_search():  
    cnt = 0
    for t in T:
        for s in S:
            if t == s:
                cnt += 1
                break

def linear_banpei_search():
    cnt = 0
    for target in T:
        cnt = search_banpei(S, target, cnt)
    return cnt

cnt = linear_banpei_search()

print(cnt)

Solution (Python):

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

def search_banpei(array, target, cnt):
    tmp = array[len(array)-1]
    array[len(array)-1] = target

    n = 0
    while array[n] != target:
        n += 1

    array[len(array)-1] = tmp
    if n < len(array) - 1 or target == tmp:
        cnt += 1
    return cnt        

def linear_search():  
    cnt = 0
    for t in T:
        for s in S:
            if t == s:
                cnt += 1
                break
    return cnt

def linear_banpei_search():
    cnt = 0
    for target in T:
        cnt = search_banpei(S, target, cnt)
    return cnt

cnt = linear_search()

print(cnt)

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

print(ans)

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

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

c = 0
for x_t in t:
    for x_s in s:
        if x_t == x_s:
            c += 1
            break

print(c)

Solution (Python):
def main():
    n = int(stdinput())
    S = [*map(int, stdinput().split())]
    q = int(stdinput())
    T = [*map(int, stdinput().split())]

    S = sorted(S)
    T = sorted(T)

    i = j = c = 0

    while i < n and j < q:
        if S[i] == T[j]:
            c += 1
            i += 1
            j += 1
        elif S[i] > T[j]:
            j += 1
        else:
            i += 1
    
    print(c)

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()

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

c = set()

for s in S:
    for q in Q:
        if s == q:
            c.add(s)

print(len(c))

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

c = 0

def seach(A, n, key):
    i = 0
    A = A + [key]
    while A[i] != key:
        i += 1
    return i != n

for q in Q:
    if seach(S, N, q):
        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()]
ans = 0
for i in range(q):
    for j in range(n):
        if t[i] == s[j]:
            ans += 1
            break
print(ans)

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

Solution (Python):
def main():
    N = int(input())
    S = [int(_) for _ in input().split()]
    Q = int(input())
    T = [int(_) for _ in input().split()]

    ans = 0

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

    print(ans)

main()

Solution (Python):
def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0


N1 = int(input())
arr1 = list(set([int(n) for n in input().split()]))
N2 = int(input())
arr2 = list(set([int(n) for n in input().split()]))

print(sum([linearSearch(key, arr2) for key in arr1]))

Solution (Python):
def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0


N1 = int(input())
arr1 = [int(n) for n in input().split()]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1) for key in arr2]))

Solution (Python):
def linearSearch(key, list, N):
    l = list + [key]
    i = 0
    while l[i] != key:
        i += 1
    return int(i != N)


N1 = int(input())
arr1 = [int(n) for n in input().split()]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1, N1) for key in arr2]))

Solution (Python):
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
count = 0
for a in t:
    for b in s:
        if a == b:
            count += 1
            break

print(count)

Solution (Python):
def linearSearch(key, list, N):
    list[N] = key
    i = 0
    while list[i] != key:
        i += 1
    return int(i != N)


N1 = int(input())
arr1 = [int(n) for n in input().split()] + [0]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1, N1) for key in arr2]))

Solution (Python):
def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0


N1 = int(input())
arr1 = [int(n) for n in input().split()]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1) for key in arr2]))

Solution (Python):
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
count = 0
for a in t:
    for b in s:
        if a == b:
            count += 1
            break

print(count)

Solution (Python):
def linear_search(s,t):
    count = 0
    check_list = []
    for i in s:
        for j in t:
            if i == j and (j in check_list) == False:
                count = count + 1
                check_list.append(j)
    return count

sline = []
tline = []

n = int(input())

sline = list(map(int,input().split()))
if len(sline) != n:
    print("Error")
    exit()

q = int(input())

tline = list(map(int,input().split()))
if len(tline) != q:
    print("Error")
    print(len(tline),q)
    exit()

count = linear_search(sline,tline)

print(count)

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())
L = input().split()
n = int(input())
l = input().split()
dup = []
count = 0
for i in range(N):
    for j in range(n):
        if L[i] == l[j]:
            dup.append(L[i])
            break
dup = list(set(dup))
print(len(dup))

Solution (Python):

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


m = int(input())
b = list(map(int, input().split()))


count = 0
for i in range(m):
    for j in range(n):
        if(b[i] == a[j]):
            count += 1
            break

print(count)

Solution (Python):

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


m = int(input())
b = list(map(int, input().split()))


count = 0
for i in range(m):
    for j in range(n):
        if(b[i] == a[j]):
            count += 1
            break

print(count)

Solution (Python):


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


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

for j in range(q):
    if T[j] in S1:
        count+=1
    
        
print(count)

Solution (Python):


n = int(input())
s = list(input().split())
n = int(input())
t = list(input().split())
cnt = 0
for i in range(n):
    if t[i] in s:
        cnt += 1

print(cnt)

Solution (Python):
n = int(input())
S = [int(t) for t in input().split()]
q = int(input())
T = [int(t) for t in input().split()]
assert n == len(S) and q == len(T)

print(sum(1 for t in T if t in S))

Solution (Python):



n = input()
s = set(input().split())
q = input()
t = set(input().split())
print(len(s & t))

Solution (Python):
n = int(input())
S =input().split(" ")
l =int(input())
T = input().split(" ")
ans =0
for t in T:
    S.append(t)
    j =0
    while S[j] !=t:
        j+=1
    if j !=n:
        ans +=1
    S=S[:-1]
print(ans)

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):
def run():
    s_n = int(input())
    S = set(map(int, input().split()))
    t_n = int(input())
    T = set(map(int, input().split()))

    print(len(S&T))

if __name__ == '__main__':
    run()

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

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

x = set(S) & set(T)
print len(x)

Solution (Python):
n = raw_input()
S = set(raw_input().split())

q = raw_input()
T = set(raw_input().split())

print len(S & T)

Solution (Python):

from __future__ import division, print_function
from sys import stdin
stdin.readline()
s = {int(s) for s in stdin.readline().split()}
stdin.readline()
s.intersection_update((int(s) for s in stdin.readline().split()))
print(len(s))

Solution (Python):



import time
import sys
import io
import re
import math
start = time.clock()
i = 0
m=int(raw_input())
n=map(int, raw_input().split())
o=int(raw_input())
p=map(int, raw_input().split())
for j in xrange(o):
    if int(p[j]) in n: i+=1
print i

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

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

Solution (Python):
n1 = int(input())
s1 = set(map(int, input().strip().split()))
n2 = int(input())
s2 = set(map(int, input().strip().split()))
print(len(s1 & s2))

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

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

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

Solution (Python):
a_N = int(input())
a_list = list(map(int, input().split()))
b_N = int(input())
b_list = list(map(int, input().split()))

answer = 0
for i in b_list:
  if i in a_list:
    answer += 1

print(answer)

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 range(q):
  for j in range(n):
    if s[j]==t[i]:
      ans+=1
      break
print(ans)

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 range(Q):
    if T[i] in S:
        C+=1
print(C)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
S = LI()
q = I()
T = LI()
ans = 0
for t in T:
    if t in S:
        ans += 1
print(ans)

Solution (Python):
from sys import stdin

n = int(input())
S = stdin.readline().split()
q = int(input())
T = stdin.readline().split()

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

print(cnt)

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

ans = 0
for t in T:
    if linear_search(S, n, t):
        ans += 1
print(ans)

Solution (Python):
def linerSearch(A, key):
    for i in A:
        if i == key:
            return 1
    return 0

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

Solution (Python):
_, s, _, t = [[*map(int, o.split())] for o in open(0)]
print(sum(i in s for i in t))

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

print(len(S & T))

Solution (Python):
def main():
    m = int(input())
    a = set(map(int, input().split()))
    n = int(input())
    b = set(map(int, input().split()))
    print(len(a & b))


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    int(input())
    S = [int(i) for i in input().split()]
    int(input())
    T = [int(i) for i in input().split()]

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

    print(count)


if __name__ == "__main__":
    main()

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

ans = 0


for i in range(q):
    key = T[i]
    for j in range(n):
        if key == S[j]:
            ans += 1
            break
        else:
            continue

print(ans)

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

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

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:
    if i in S:
        c += 1

print(c)

Solution (Python):
def main():
    import sys
    asa =  sys.stdin.readline
    n = int(input())
    s = list(map(int, asa().split()))
    q = int(input())
    t = list(map(int, asa().split()))
    
    c = 0
    s.append(0)
    
    for i in t: 
        j = 0
        s[n] = i
        while s[j] != i:
            j += 1
        if j < n:
            c += 1
            
    print(c)
        
    
if __name__ == '__main__':
    main()

Solution (Python):
_, S = input(), input().split()
_, T = input(), input().split()
print(sum(t in S for t in T))

Solution (Python):
n = int(input())
S = list(map(int, input().split()))
S.append(0)
q = int(input())
T = list(map(int, input().split()))
N = 0
for t in T:
    i = 0
    S[n] = t
    while S[i] != t:
        i += 1
    if i != n:
        N += 1
print(N)

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):
    t = T[i]
    for j in range(n):
        if S[j] == t:
            count += 1
            break

print(count)

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):
tmp=input()
a=input().split()
tmp=input()
b=input().split()
c=0
for i in b:
    if i in a:
        c+=1
print(c)

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):
    for j in range(n):
         if t[i]==s[j]:
             count+=1
             break
print(count)

Solution (Python):

n = input()
S = map(lambda x: int(x), input().split(' '))
q = input()
T = list(map(lambda x: int(x), input().split(' ')))


T_set = set(T)


count = 0
for i in S:
    if i in T_set:
        count += 1
        T_set.remove(i)

print(count)

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

N = int(input())
S = [int(x) for x in input().split(" ")]
S.append(None)


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

count = 0

for key in T:
    if LinearSearch(S,N,key):
        count += 1
print(count)

Solution (Python):
n = int(input())
s = list(input().split())
q = int(input())
t = list(input().split())
ans = 0
for num in t:
    if num in s:
        ans += 1
print(ans)

Solution (Python):
nS = int(input())
S = list(map(int,input().split()))
nQ = int(input())
Q = list(map(int,input().split()))

cnt = 0

for i in range(nQ):
    copy_S = S.copy()
    copy_S.append(Q[i])

    j = 0
    while copy_S[j] != Q[i]:
        j += 1
    if j < len(copy_S)-1 : cnt += 1

print(cnt)

Solution (Python):
input()
li1 = [int(x) for x in list(input().split())]
input()
li2 = [int(x) for x in list(input().split())]

counter = 0
for i in li2:
    if i in li1:
        counter += 1
print(counter)

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

Solution (Python):
def linear_search(s, n, key):
    for i in s:
        if i == key:
            return 1
    return 0

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 linear_search(s, n, i) != 0:
        ans += 1
print(ans)

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

count = 0
for _t in t:
    for _s in s:
        if _t == _s:
            count += 1
            break
print(count)

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

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

print(len([t for t in T if t in S]))

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque
import copy

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def linear_search(S, n, key):
    i = 0
    S[n] = key
    while S[i] != key:
        i += 1
    return i != n


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = il()
    Q = ii()
    T = il()

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


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:
    m = 0
    S.append(i)
    while i != S[m]:
        m+=1
    if m != n:
        cnt+=1
    S.pop()
print(cnt)

Solution (Python):
n1 = int(input())
nums1 = list(map(int, input().split()))
n2 = int(input())
nums2 = list(map(int, input().split()))

def linear_search(nums1, n1, key):
    nums1[n1] = key
    index = 0
    while nums1[index] != key:
        index += 1
    return index != n1

output = 0
nums1.append(None)
for key in nums2:
    if linear_search(nums1, n1, key):
        output += 1

print(output)

Solution (Python):
n = int(input())
str = input().split(" ")
S = [int(str[i]) for i in range(n)]
q = int(input())
str = input().split(" ")
T = [int(str[i]) for i in range(q)]

S_set = set(S)
S = list(S_set)
T.sort()

result = 0

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

print(result)

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

print(sum(1 for i in t if i in s))

Solution (Python):
from collections import deque
import sys
input = sys.stdin.readline

_ = int(input())
S = [int(i) for i in input().strip().split()]
_ = int(input())
T = [int(i) for i in input().strip().split()]

ans = 0
for t in T:
    if t 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()))
cnt = 0
for i in range(q) :
    if T[i] in S :
        cnt += 1
print(cnt)

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

if __name__ == '__main__':
    main()

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

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

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

print(count)