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

print(cnt)

Solution (Python):
def search_linear(target_list, target_length, key_value):
    i = 0
    target_list.append(key_value)
    while target_list[i] != key_value:
        i += 1
    target_list.pop()
    return i != target_length

target_length = int(input())
target_list = list(map(int,input().split()))
key_length = int(input())
key_list = list(map(int,input().split()))

exist_count = 0
for key_value in key_list:
    exist_count += 1 if search_linear(target_list, target_length, key_value) else 0
print(exist_count)

Solution (Python):
def func(n, t, q, s):
    matchN = 0
    t.append(0)
    for x in s:
        t[n] = x
        i = 0
        while t[i] != x:
            i += 1
        if i != n:
            matchN += 1
    return matchN

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

Solution (Python):



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

cnt = 0






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

print(cnt)

Solution (Python):
def main():
    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)
    
if __name__ == '__main__':
    main()

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 linearSearch(A, n, key):
	i = 0
	A.append(key) 
	while A[i] != key:
		i += 1
	A.pop(-1) 
	return i != n 


if __name__ == "__main__":
	n = int(input())
	S = list(map(int, input().split()))
	q = int(input())
	sum = 0
	for key in list(map(int, input().split())):
		if linearSearch(S, n, key):
			sum += 1
	print(sum)

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

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

Solution (Python):
n = int(input())
NUM_LIST = list(map(int, input().split()))
k = int(input())
keys = list(map(int, input().split()))
cnt = 0
for key in keys:
    if key in NUM_LIST:
        cnt+= 1
print(cnt)

Solution (Python):





import copy

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

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

def liner_search(nums, n, v):
    S_copy = copy.deepcopy(nums)
    S_copy.append(v)
    i = 0
    while S_copy[i] != v:
        i += 1 
    
    return i != n


if __name__ == "__main__":
    count = 0 
    for t in T:
        if liner_search(S, Sn, t):
            count += 1

    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 s.count(i) > 0:
        cnt += 1
print(cnt)

Solution (Python):
input()
S=list(map(int,input().split()))
input()
T=list(map(int,input().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()))

print(len(list(filter(lambda x: x in t, set(s)))))

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.intersection(t)))

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

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

for x in S:
    for y in T:
        if x==y:
            count+=1

print(count)

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

sort_S = list(sorted(S[:]))
sort_T = list(sorted(T[:]))
i, j = 0, 0
ans = 0
while i < n and j < q:
    if sort_S[i] == sort_T[j]: 
        ans += 1
        i += 1
        j += 1
    elif sort_S[i] > sort_T[j]:
        j += 1
    elif sort_S[i] < sort_T[j]:
        i += 1
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()]

count = 0

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

print(count)

Solution (Python):

n=input()
s=list(map(int,input().split()))
q=input()
t=list(map(int,input().split()))
count=0
for i in t:
    j=0
    s.append(i)
    while s[j]!=i:j +=1
    s.pop()
    if j==int(n):continue
    else:count +=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)

Solution (Python):
input()
a = list({int(i) for i in input().split()})
a.sort()
input()
print([int(i) in a for i in input().split()].count(True))

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)

Solution (Python):
import sys
s=int(input())
S=list(map(int,input().split()))
t=int(input())
T=list(map(int,input().split()))
S=list(set(S))
ans=0
for i in range(len(S)):
  for j in range(t):
    if S[i]==T[j]:
      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
for a in t:
    if a in s:
        ans+=1

print(ans)

Solution (Python):

num = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]


count = 0
for k in t:
    for l in s:
        if k == l:
            count += 1
            break

print(count)

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

cnt = 0
q = int(input())
t = list(map(int, input().split()))
for i in t:
    if i in s:
        cnt += 1

print(cnt)

Solution (Python):
import sys

def test():

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

	for i in range(len(T)):

		for j in range(len(S)):

			if T[i] == S[j]:
				S.pop(j)
				break
	print(f"{n-len(S)}")

if __name__ == "__main__":
	test()

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 j == i:
            cnt += 1
            break

print(cnt)

Solution (Python):
n_count = int(input())
n = set(map(int, input().split()))

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

n_and_q = 0

for i in q:
    if i in n:
        n_and_q += 1
        
print(n_and_q)

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

C = 0
for t in T:
    if t 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()))
count=0
for i in t:
	for j in s:
		if i==j:
			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()))
ans=0
s.sort()
for i in range(n):
    for j in range(q):
        if s[i]==s[i-1]:
            continue
        else:
            if s[i]==t[j]:
                ans+=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 i in range(q):
    t = T[i]
    for j in range(n):
        if S[j] == t:
            c += 1
            break
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(" ")]
searched = []

def linearSearch(target, t, q):
    res = 0
    t[q] = target
    j = 0
    while target!=t[j]:
        j += 1
    if j != q:
        res += 1
    return res    

cnt = 0
t.append("NIL")
for i in range(n):
    target = s[i]
    if target in searched:
        continue
    searched.append(target)
    
    cnt += linearSearch(target, t, q)
    
print(cnt)

Solution (Python):
n_num = int(input())
n_list = input().split()
q_num = int(input())
q_list = input().split()

cnt = 0
for q in q_list:
    if q in n_list:
       cnt += 1

print(cnt)

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

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

ans = 0
s,t = 0,0
while s < len(S) and t < len(T):
    if S[s] == T[t]:
        ans += 1
        t += 1
    elif S[s] < T[t]:
        s += 1
    else:
        t += 1
print ans

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

def main():
    n = int(input())
    S = input().split(" ")
    _ = int(input())
    T = input().split(" ")

    sum = 0

    for s in T:
        if linearSearch(S, n, s):
            sum += 1
    
    print(sum)

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

def LinearSearch(S,T):
    count = 0
    for i in range(q): 
        for j in range(n): 
            if T[i] == S[j]:
                count += 1
                break
    return count

print(LinearSearch(S,T))

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

"""
5
1 2 3 4 5
3
3 4 1
"""

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

def fun(S,T):
        c = 0
        for i in T:
                if i in S:
                        c+=1
        return c

print(fun(S,T))

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

def search(lst, n, val):
    for i in range(n):
        if lst[i] == val:
            return True
    return False

ans = 0
for i in range(q):
    if search(s, n, t[i]):
        ans += 1

print(ans)

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 = [int(x) for x in input().split()]
 
q = int(input())
T = [int(x) for x in input().split()]
 
ans = 0
for i in range(q):
    find = 0
    for j in range(n):
        if S[j] == T[i]:
            find = 1
    ans = ans + find
print(ans)

Solution (Python):
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
N = int(input())
S = list(map(int,input().split()))
 
DICT = {}
 
for i in range(len(S)):
    DICT[S[i]] = True
 
Q = int(input())
T = list(map(int,input().split()))
 
ans = 0
 
for i in range(len(T)):
    if DICT.__contains__(T[i]):
        ans += 1
 
print("%d"%(ans))

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

for ti in t:
  if ti in s:
    result += 1

print(result)

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

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    S = input().split()
    q = int(input())
    T = input().split()
    a = []
    count = 0
    for i in range(q):
        for j in range(n):
            if int(T[i]) == int(S[j]): 
                if T[i] in a: break
                else :
                    a.append(T[i])
                    count += 1
                    break
    print(str(count))

Solution (Python):
def main():
    _ = int(input())
    ns = list(map(int, input().split(' ')))
    _ = int(input())
    qs = list(map(int, input().split(' ')))
    count = 0
    for q in qs:
        for n in ns:
            if n == q:
                count += 1
                break
    print(count)


if __name__ == '__main__':
    main()

Solution (Python):
import collections


if __name__ == "__main__":
    S_num = int(input())
    S = collections.Counter(set(map(lambda x: int(x), input().split())))
    T_num = int(input())
    T = list(map(lambda x: int(x), input().split()))

    print(f"{sum(map(lambda x: S[x], T))}")

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

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

r = linearSearch(S, T)
print(r)

Solution (Python):
if __name__ == '__main__':
	n = int(input())
	S = list(set([int(i) for i in input().split()]))
	q = int(input())
	T = [int(i) for i in input().split()]
	
	c = 0
	for i in S:
		if i in T:
			c+=1
	print(c)

Solution (Python):
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 T:
        for j in S:
            if i == j:
                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()))

cnt = []
for i in s:
    if i in t:
        cnt.append(i)
print(len(set(cnt)))

Solution (Python):
"""


 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    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()))
    c=0
    for i in T:
        if i 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()))

c=0

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

Solution (Python):
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
S = Counter(int(_) for _ in stdin.readline().rstrip().split())
Q = int(stdin.readline().rstrip())
T = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in T:
    if i in S:
        ans += 1
print(ans)

Solution (Python):
if __name__ == '__main__':
    n = int(raw_input())
    S = map(int, raw_input().split())
    S.append(0)
    q = int(raw_input())
    T = map(int, raw_input().split())
    cnt = 0
    for x in T:
        S[n] = x
        i = 0
        while S[i] != x:
            i += 1
        if i != n:
            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:
    if i in s:
        cnt+=1
print(cnt)

Solution (Python):
n = int(input())
v = list(map(int,input().split()))
q = int(input())
w = list(map(int,input().split()))
for i in v:
    for j in range(len(w)):
        if w[j]==i:
            del w[j]
            break
print(q-len(w))

Solution (Python):
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

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

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


ans = 0
for key in T:
    if key in S:
        ans += 1
print("%d"%(ans))

Solution (Python):
class Search():
    def __init__(self,N,input_S):
        self.sum = 0
        self.N = N
        self.input_S = input_S
        input_S.append(0)
    def search(self,key):
        self.input_S[self.N] = key
        i = 0
        while(self.input_S[i]!=key):
            i += 1
        if i != self.N:
            self.sum += 1
def main():
    N = int(input())
    input_S = [int(i) for i in input().split()]
    M = int(input())
    input_T = [int(i) for i in input().split()]
    linear_search = Search(N,input_S)
    for i in range(len(input_T)):
        linear_search.search(input_T[i])
    print(linear_search.sum)

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
As = list(map(int, input().split()))
q = int(input())
Ts = list(map(int, input().split()))

ans = 0
for T in Ts:
    for A in As:
        if T == A:
            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()))

cnt = 0

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

print(cnt)

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

count = 0
for t in t_list:
    for s in s_list:
        if s == t:
            count = count + 1
            break

print(count)

Solution (Python):
def solve():
    n = int(input())
    S = [int(s) for s in input().split(' ') if s]
    q = int(input())
    T = [int(s) for s in input().split(' ') if s]
    ret = 0
    for t in T:
        if t in S:
            ret += 1

    print(ret)
    
solve()

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

print(sum(x in s for x in arr))

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







for i in range(q):
    for j in range(n):
        if numsB[i] == numsA[j]:
            count += 1
            break

print(count)

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

for j in range(q):
    S=S+[T[j]]
    i=0
    while S[i]!=T[j]:
        i+=1
        if i==n:
            C[j]=1
c=0
for j in range(q):
    if C[j]==0:
        c+=1
print(c)

Solution (Python):
def main():
    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 t[i] == s[j]:
                ans += 1
                break
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def linear_search_2(sequence, key):
    i = 0
    sequence_guard = sequence[:]
    sequence_guard.append(key)

    while sequence_guard[i] != key:
        i += 1

    if i == len(sequence):
        return "NOT_FOUND"

    return i



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

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

cnt = 0

for t in T:
    
    result = linear_search_2(S, t)
    
    if result == "NOT_FOUND":
        continue
    
    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 = 0
for i in range(q):
  if t[i] in s:
    c += 1
print(c)

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

for i in t:
    for j in s:
        if i==j:
            ans=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()))


count = 0
for i in t:
    for j in s:
        if i == j:
            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()))

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

print(c)

Solution (Python):
n=int(input())
N = list(map(int, input().split()))
q = int(input())
Q = list(map(int, input().split()))

ct = 0
for i in range (q):
  for j in range (n):
    if Q[i] == N[j]:
      ct += 1
      break
print(ct)

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

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

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

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

n2 = int(input())
b = list(map(int, input().split()))
b = set(b)

count = 0
for i in a:
    for j in b:
        if i == j:
            count += 1
print(count)

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

Solution (Python):
def _main():
  N = int(input())
  lst = list(map(int, input().split()))
  K = int(input())
  key_lst = list(map(int, input().split()))

  ans = 0
  for k in range(K):
    if search(lst, key_lst[k]): ans += 1

  print(ans)

def search(lst, key):
  lst.append(key)
  i = 0
  while lst[i] != key:
    i += 1
  lst.pop()
  return len(lst) != i

if __name__ == '__main__':
  _main()

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


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


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

Solution (Python):
count = 0
n1 = int(input())
s = list(map(int, input().split()))
n2 = int(input())
t = list(map(int, input().split()))
used = []
for tt in t:
  for ss in s:
    if tt == ss and tt not in used:
      used.append(tt)
      count += 1

print(count)

Solution (Python):
n = input()
list_S = input().split()

m = input()
list_T = input().split()

print(*[sum(1 for t in list_T if t in list_S)])

Solution (Python):
input()
s = [int(i) for i in input().split()]
input()
t = [int(i) for i in input().split()]
sd, td = {}, {}
for i in s:
    if i in sd:
        sd[i] += 1
    else:
        sd[i] =1
for i in t:
    if i in td:
        td[i] += 1
    else:
        td[i] =1
c = 0
for i in td.keys():
    if i in sd.keys():
        c += 1
print(c)

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

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

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

print(sum)

Solution (Python):

def linear_search(target, nums):
    for num in nums:
        if num == target:
            return True
    return False

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 linear_search(t, S):
        count += 1
        
print(count)

Solution (Python):
if __name__ == "__main__":
    N = int(input())
    S = list(map(int, input().split()))
    S.extend([-1, float('inf')])
    S.sort()
    
    Q = int(input())
    T = list(map(int, input().split()))
    ans = 0
    for ti in T:
        for sj in S:
            if sj==ti:
                ans += 1
                break

    print(ans)

Solution (Python):
input()
a=list(map(int,input().split()))
n=int(input())
b=list(map(int,input().split()))
d={}


def s(bannpei):
    i=0
    c=b+[bannpei]
    while c[i]!=bannpei:
        i+=1
    if i==n:
        return False
    return True
for r in a:
    if s(r):
        d[r]=1
print(sum(d.values()))

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):
n=int(input())
list_n = list(map(int,input().split()))
q=int(input())
list_q=list(map(int,input().split()))
cnt=0
for i in list_q:
    if i in list_n:
        cnt +=1
print(cnt)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
count = 0
b = [int(j) for j in input().split()]
for j in range(0,q):
    for i in range(0,n):
        if a[i] == b[j]:
            count = count + 1
            break
print(count)

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

print(len(S & T))

Solution (Python):
a1 = int(input())
a2 = list(map(int,input().split(" ")))
b1 = int(input())
b2 = list(map(int,input().split(" ")))

count = 0
for i in b2:
    a2.append(i)
    k = 0
    while True:
        if a2[k] == i:
            break
        k += 1
    if not k == len(a2)-1:
        count += 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)

Solution (Python):
n = int(input())
SS = [int(i) for i in input().split()]
q = int(input())
TS = [int(i) for i in input().split()]


print(sum([1 for t in TS if t in SS]))

Solution (Python):
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

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


    n = int(input())
    a = input().split()
    a.append(None)
    q = int(input())
    t = input().split()

    sum_ = 0
    for key in t:
        if search(a, n, key):
            sum_ += 1
    print(sum_)

Solution (Python):
n1 = int(input())
nums1 = list(map(int, input().split(' ')))
n2 = int(input())
nums2 = list(map(int, input().split(' ')))
sum = 0
for i in range(n2):
    j = 0 
    nums1.append(nums2[i])
    while nums1[j] != nums2[i]:
        j += 1
    if j != n1:
        sum += 1
    nums1.pop()
print(sum)

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

n = int(input())
S = input().strip().split()

q = int(input())
T = input().strip().split()
count = 0
for i in range(len(T)):
    S.append(T[i])
    j = 0
    while S[j] != T[i]:
            j += 1
    if j != len(S[:-1]):
        count += 1
    S = S[:-1]
print(count)

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

ans = 0
for tt in t:
    for ss in s:
        if ss == tt:
            ans += 1
            break

print(ans)

Solution (Python):
_ = input()
s = set(map(int, input().split()))
_ = 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()))
C = 0
for i in range(q):
    if T[i] in S:
        C += 1
print(C)

Solution (Python):

input()
S = set(input().split())
input()
s = set(input().split())
print(len(S & s))

Solution (Python):

def judge(array, key):
    if key in array:
        return True
    else :
        return False

s_length = int(input())
array_s = [int(i) for i in input().split()]
t_length = int(input())
array_t = [int(i) for i in input().split()]

cnt = 0
for i in range(t_length):
    key = array_t[i]
    if judge(array_s, key):
        cnt += 1

print(cnt)

Solution (Python):
n=int(input())
s=list(set(list(map(int,input().split()))))
q=int(input())
t=list(set(list(map(int,input().split()))))
print(len(s)+len(t)-len(set(s+t)))

Solution (Python):

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

print(count)

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

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

cnt = 0
for tmpT in T:
    for tmpS in S:
        if tmpT == tmpS:
            cnt += 1
            break

print(cnt)

Solution (Python):
num = int(input())
array = input().split()
 
num2 = int(input())
array2 = input().split()
 
count = 0
for i in range(num2):
        if array2[i] in array:
                count += 1
 
print(count)

Solution (Python):
import sys,itertools
input = sys.stdin.readline

def search(t, S):
    for s in S:
        if s == t:
            return 1
    return 0

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

cnt = 0
for t in T:
    cnt += search(t, S)

print(cnt)

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
m=int(input())
B=list(map(int,input().split()))
cnt=0
for i in B:
    for j in A:
        if i==j:
            cnt+=1
            break
            
print(cnt)

Solution (Python):
l=[]
for _ in range(4):l+=[set(input().split())]
print(len(l[1]&l[3]))

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

Solution (Python):
from sys import stdin

stdin.readline().rstrip()
S = [int(x) for x in stdin.readline().rstrip().split()]
S.sort()
stdin.readline().rstrip()
T = [int(x) for x in stdin.readline().rstrip().split()]

C = 0
for ti in T:
    for si in S:
        if ti == si:
            C += 1
            break

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

count = 0
index = []
for i in range(n):
    for j in range(q):
        if s[i]==t[j]:
            for k in range(len(index)):
                if t[j]==index[k]:
                    break
            else:
                count += 1
                index.append(t[j])
            
print(count)

Solution (Python):
import sys

def InputData():

    data_len = int(input())
    
    data = list(map(int, input().split()))

    searchdata_len = int(input())
    
    searchdata = list(map(int, input().split()))

    
    

    return data_len, data, searchdata_len, searchdata

def Liner_Search(data, key):

    contained_cnt = 0
    
    for i in range(len(data)):
        if key == data[i]:
            return 1
    
    
    return "NOT_FOUND"

def PrintOut(contained_cnt):
    print(int(contained_cnt))

def main():
    [data_len, data, searchdata_len, searchdata] = InputData()
    count = 0
    for i in searchdata:
        if Liner_Search(data, i)  != "NOT_FOUND":
            count += 1
    
    PrintOut(count)

if __name__=='__main__':
    main()