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 = [int(item) for item in input().split()]
q = int(input())
T = [int(item) for item in input().split()]


def banhei():
    cnt = 0
    for i in range(q):
        key = T[i]
        S.append(key)
        j = 0
        
        while key != S[j]:
            j += 1
        if j != N:
            
            cnt += 1
        S.pop()
    return cnt

print(banhei())

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

def linearSearch(A,key,n):
    i=0
    B=copy.copy(A)
    B.append(key)
    while B[i] != key:
        i=i+1
    if i==n:
        return 0
    return 1

ans=0
for i in range(q):
    if linearSearch(S,T[i],n):
        ans=ans+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

S.append(None)

def lenearSearch(s, t):
    i = 0
    while S[i] != t:
        i += 1
    return i != (len(s)-1)

for t in T:
    S[-1] = t
    if lenearSearch(S, t):
        count+=1

print(count)

Solution (Python):
def search(l:list, t:int) -> bool:
    l.append(t)
    i=0
    while l[i] != t:
        i+=1

    if len(l) == i+1:
        return False
    l.pop()
    return True

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 search(s, _t):
            ans+=1

print(ans)

Solution (Python):
import sys
import math
import copy
from typing import Tuple, List, Union
input = sys.stdin.readline


def main():
    n = int(input())
    S = tuple(map(int,input().split()))
    q = int(input())
    T = tuple(map(int,input().split()))
    res = 0
    for t in T:
        for s in S:
            if s == t:
                res += 1
                break
    return res


if __name__ == '__main__':
    print(main())

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

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

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

Solution (Python):
_,s1 = input(), set(input().split())
_,s2 = input(), set(input().split())
print(len(s1 & s2))

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

a = set(a)
b = set(b)

print(len(a&b))

Solution (Python):
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

def SI():
    return int(readline())
def MI():
    return map(int, readline().split())
def MLI():
    return map(int, open(0).read().split())

inf = float("inf")


def main():
    n = int(input())
    S = [i for i in MI()]
    
    q = int(input())
    T = [i for i in MI()]
    
    ret = 0
    for t in T:
        if t in S:
            ret += 1
            
    print(ret)

if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter

N = int(input())
S = Counter(map(int, input().split()))
Q = int(input())
T = Counter(map(int, input().split()))
ans = 0
if len(S) > len(T):
    for x, y in S.items():
        if x in T.keys():
            ans += min(y, T[x])
else:
    for x, y in T.items():
        if x in S.keys():
            ans += min(y, S[x])
print(ans)

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

count = 0
for t in T:
    if t in S:
        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(set(s) & set(t)))

Solution (Python):
def use_guard():
    same_num_count = 0
    firstlist_num = int(input())
    firstlist = set(input().split())
    secondlist_num = int(input())
    secondlist = set(input().split())

    for n in secondlist:
        if firstlist.__contains__(n):
            same_num_count += 1

    print(same_num_count)

def use_set():
    input()
    firstlist = set(input().split())
    input()
    secondlist = set(input().split())
    same_num_count = len(firstlist.intersection(secondlist))
    print(same_num_count)

use_set()

Solution (Python):
from collections import deque

def linear():
    
    s = deque()
    t = deque()
    n = int(input())
    s_list = list(map(int, input().split()))
    q = int(input())
    t_list = list(map(int, input().split()))
    for i in s_list:
        s.append(i)
    for i in t_list:
        t.append(i)

    
    count = 0
    for i in t:
        f = True
        while True:
            try:
                s.remove(i)
                if f:
                    count += 1
                    f = False
            except ValueError:
                break
    print(count)

if __name__ == "__main__":
    linear()

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(len(t)):
    if t[i] in s:
        count += 1

print(count)

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

    count = 0

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

    print(count)

main()

Solution (Python):
n1 = int(input())
a = [ int(i) for i in input().split(" ")]
n2 = int(input())
b = [ int(i) for i in input().split(" ") ]

ans = 0
for e in b:
  if e in a: ans += 1

print(ans)

Solution (Python):
a=input() 
S = input().split()
b=input()
T = input().split()
count = 0

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

print(count)

Solution (Python):






def linear_search(A: list, key: int) -> int:
    i = 0
    
    A.append(key) 

    while A[i] != key:
        i += 1
        if i == len(A)-1:
            return -1

    return i

def main():

    number_of_A = int(input())
    A = [int(a) for a in input().split(" ")]


    number_of_B = int(input())
    B = [int(b) for b in input().split(" ")]

    num = 0
    for b in B:
        result = linear_search(A, b)
        if result != -1:
            num += 1

    print(num)


if __name__ == "__main__":
    main()

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

Solution (Python):

def linearSearch(list, find_number):
    i = 0
    search_list = list + [find_number]
    last_number = len(search_list) - 1
    while search_list[i] != find_number:
        i += 1
    if i ==  last_number:
        return 0
    else:
        return 1


n_number = int(input())
n_list = list(map(int, input().split()))
q_number = int(input())
q_list = list(map(int, input().split()))
result = 0


for i in range(q_number):
        result += linearSearch(n_list, q_list[i])


print(result)

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

Solution (Python):


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

S.sort()
T.sort()
ans = 0

i = 0
for elm in S:
    if elm > T[i]:
        while i < q-1 and elm > T[i]:
            i += 1
        
        if elm == T[i]:
            ans += 1
    elif elm == T[i]:
        ans += 1
    elif elm < T[i]:
        pass

print(ans)

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

Solution (Python):
input()
s = set(list(map(int,input().split())))
input()
t = set(list(map(int,input().split())))
print(len(s.intersection(t)))

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

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


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

count = 0

for i in range(q):
    S.append(0)
    S[n]=T[i]   
    count += lineresearch(S[n])
print(count)

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

n = int(input())
S = input().split()
q = input()
T = input().split()
ans = 0
for t in T:
    ans += linear_search(t, S)
print(ans)

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

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

S.append(0)
count = 0
for a in T:
  if (search(S, n, a)):
    count += 1

print (count)

Solution (Python):



def linearSearch(l, key):
  index = 0
  l.append(key)
  while l[index] != key:
    index += 1
  else:
    if index == (len(l) -1):
      return -1
    else:
      return index

def main():
  n = int(input())
  S = list(map(int, input().split()))
  m = int(input())
  T = list(map(int, input().split()))
  count = 0
  for i in T:
    if linearSearch(list(S), i) != -1:
      count += 1
  print(count)

main()

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

count = 0

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

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

count = 0
for t in T:
    min_idx = 0
    max_idx = len(S) - 1
    while min_idx <= max_idx:
        mid_idx = (min_idx+max_idx) // 2
        if t < S[mid_idx]:
            max_idx = mid_idx - 1
        elif t > S[mid_idx]:
            min_idx = mid_idx + 1
        else:
            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=list(set(s) & set(t))
print(len(ans))

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

    c = 0

    for k in T:
        if k in S:
            c += 1
    print(c)

if __name__ == "__main__":
    main()

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

Solution (Python):
num_s, S, num_t, T,  = [list(map(int, s.split())) for s in open(0)]
cnt = 0
for t in T:
    if t in S:
        cnt += 1
print(cnt)

Solution (Python):
input()
s = input().split()
input()
t = input().split()
ans = len([i for i in t if i in s])
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 t in T:
    if t in S:
        cnt = 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())
	L = list(map(int, input().split()))

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

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

Solution (Python):
n = int(input())                                                                          
ls_s = list(map(int,input().split()))                                                     
q = int(input())                                                                          
ls_t = list(map(int,input().split()))                                                     
                                                                                          
ls_ch = []                                                                                
cnt = 0                                                                                   
for i in range(n):                                                                        
    flag = 0                                                                              
    for j in range(len(ls_ch)):                                                           
        if ls_s[i] == ls_ch[j]:                                                           
            flag = 1                                                                      
            break                                                                         
    if flag == 1:                                                                         
        continue                                                                          
    for j in range(q):                                                                    
        if ls_s[i] == ls_t[j]:                                                            
            cnt += 1                                                                      
            ls_ch.append(ls_s[i])                                                         
            break                                                                         
                                                                                          
print(cnt)

Solution (Python):
count = 0

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

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

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

print(count)

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

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

Solution (Python):

n1 = int(input())
A = set(map(int, input().split()))
n2 = int(input())
B = set(map(int, input().split()))

print(len(B.intersection(A)))

Solution (Python):
import sys

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

result = 0
for x in t:
    for y in s:
        if x == y: result += 1; break
print(result)

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

Solution (Python):
"""
線形探索
O(n)かかる
"""
def LinearSerch(S, T):
    count = 0
    for i in T:
        for j in S:
            if i == j:
                count += 1
                break
            else:
                pass
    
    return count

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

print(LinearSerch(s, t))

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=list(map(int, input().split()))
q=int(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 = 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 = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]
count = 0
for i in t:
    if i in s:
        count += 1   
print(count)

Solution (Python):







from copy import deepcopy


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


def main():
    
    seq1_len = int(input())
    seq1 = list(map(int, input().split(" "))) + [0]  
    
    input()
    seq2 = list(map(int, input().split(" ")))
    count = 0
    for key in seq2:
        if linear_search(seq1, seq1_len, key):
            count += 1

    print(count)


if __name__ == "__main__":
    main()

Solution (Python):
a = int(input())
alist = list(map(int,input().split()))
b = int(input())
blist = list(map(int,input().split()))
ans = 0
for num in blist:
    if num in alist:
        ans += 1
print(ans)

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

cnt = 0

def search(S,n, key):
    S[n] = key
    j = 0
    while( S[j] != key):
        j += 1


    return j != n

for i in T:
    if(search(S,n,i)): cnt += 1

print(cnt)

Solution (Python):
def linear_search(number, list):
    i = 0
    n = len(list)
    list.append(number)
    while list[i] != number:
        i += 1
    if i == n:
        return 0
    return 1

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

Solution (Python):


import copy

def linearSearch(S, length, key):
    numList = copy.copy(S)
    numList.append(key)
    j = 0
    while numList[j] != key:
        j += 1
    return j != length
    

sum = 0
lenS = int(input())
S = list(map(int, input().split())) 
lenT = int(input())
T = list(map(int, input().split())) 

for i in range(lenT):
    tmp = linearSearch(S, lenS, T[i])
    if tmp:
        sum += 1
print(sum)

Solution (Python):
n=int(input())
s=list(map(int,input().split()))
q=int(input())
cnt=0
t=list(map(int,input().split()))
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())
S = list(map(int, input().split()))
q = int(input())
T = map(int, input().split())
T = set(T)
ans = 0
for t in T:
    ans += S.count(t) != 0
print(ans)

Solution (Python):
def linear_search(num, numlist):
    numlist.append(num)
    index = 0
    while index < len(numlist) and numlist[index] != num:
        index += 1
    numlist.pop(-1)
    if index == len(numlist):
        return False
    else:
        return True

if __name__ == '__main__':
    n = input()
    numlist1 = [int(num) for num in input().split()]
    m = input()
    numlist2 = [int(num) for num in input().split()]

    tot = 0
    for num in numlist2:
        if linear_search(num, numlist1):
            tot += 1
    print(tot)

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

print(count)

Solution (Python):
n = int(input())
S = set(input().split())
q = int(input())
T = set(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()))

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

Solution (Python):
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    input()
    s=list(map(int,input().split()))
    input()
    t=list(map(int,input().split()))
    s=set(s)
    t=set(t)
    print(len(s&t))

main()

Solution (Python):
if __name__ == "__main__":
    n = input()
    A = set(map(int, input().split()))
    n = input()
    cnt = 0
    for b in map(int, input().split()):
        cnt += b in A
    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()]

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

Solution (Python):

def linearSearch(L,n,key):
    i = 0
    L.append(key)
    while L[i] != key:
        i += 1
    L.pop(n)
    
    return i != n

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

ans = 0
for i in range(len(T)):
    if linearSearch(S,len(S),T[i]):
        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
lenS = len(S)
for i in T:
    S.append(i)
    idx = 0
    while True:
        if S[idx] == i:
            break
        else:
            idx += 1
    if idx < lenS:
        ans += 1
    S.pop()
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=list(map(int,input().split()) )
q=int(input())
t=list(map(int,input().split()) )
print( sum( i in s for i in t) )

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

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

def main():
    n,S,q,T=inputting()
    count=0
    for t in T:
        flag=linearsearch(n,S,t)
        if flag==1:
            count+=1
    print(count)
    

if __name__=='__main__':
    main()

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

main()

Solution (Python):
def LinearSearch(intList,target):
    i=0
    intList.append(target)
    while intList[i] != target:
        i+=1
    intList.pop()
    if i == len(intList):
        return False
    return True

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

for i in range(len(T)):
    if LinearSearch(S, T[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()))

def linearSearch(A: [int], key: int):
    i = 0
    A[len(A)-1] = key
    while A[i] != key:
        i += 1
    return i != n

c = 0
s.append(-1)
for i in range(len(t)):
    if linearSearch(s, t[i]):
        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 = int(input())
S = list(map(int,input().split()))
Q = int(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()))
C=len([i for i in T if i in S])
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 elT in t:
    for elS in s:
        if elT == elS:
            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

for Ti in T:
  for Si in S:
    if Si == Ti:
      ans += 1
      break

print(ans)

Solution (Python):
len_a = input()
a = set(map(int, input().split()))
len_b = input()
b = set(map(int, 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()))

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

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

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

counter = 0
for t in T:
    if search(S[:], t, n):
        counter += 1

print(counter)

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

def linear_search(A,key):
    i = 0
    A.append(key)
    n = len(A) - 1
    while A[i] != key:
        i += 1
    if i == n:
        return 0
    return 1

cnt = 0
for j in T:
    cnt += linear_search(S,j)

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

Solution (Python):


"""
Created on Thu Oct 24 00:11:24 2019

@author: iwao_yuuki
"""

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:
    flag = False
    for j in S:
        if i == j:
            cnt += 1
            flag = True
        if flag:
            break

print(cnt)

Solution (Python):

n=int(input())

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

q=int(input())

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

cou=0

for i in range(q):
    for k in range(n):
        if s[k]==t[i]:
            cou+=1
            break

print(cou)

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

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

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

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

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

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

print(c)

Solution (Python):
n = int(input())
l1 = [int(x) for x in input().split()] 
m = int(input())
l2 = [int(x) for x in input().split()] 

cnt = 0
for i in range(len(l2)):
    for j in range(len(l1)):
        if(l1[j] == l2[i]):
            cnt = 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=0

S.sort()
for i in range(n):
    for j in range(q):
        if S[i]==T[j]:
            if S[i-1]!=S[i]:
                cnt+=1
print(cnt)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    arr_1 = set(map(int, input().split()))
    q = int(input())
    arr_2 = set(map(int, input().split()))
    arr = arr_1 & arr_2
    print(len(arr))

Solution (Python):


n = int(input())
List = [int(i) for i in input().split()]
q = int(input())
List2 = [int(i) for i in input().split()]
count = 0
for i in range(q):
    count += list(set(List)).count(List2[i])
print(count)

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

S.sort()
for i in range(n):
    for j in range(q):
        if S[i] == T[j]:
            if S[i-1] != S[i]:
                cnt += 1
print(cnt)

Solution (Python):
n=int(input())
r=list(map(int,input().split()))
m=int(input())
l=list(map(int,input().split()))

r.sort()
l.sort()

c=0
for i in l:
    for j in r:
        if i==j:
            c=c+1
            break
print(c)

Solution (Python):
from collections import deque
n=int(input())
S=input().split()
q=int(input())
T=input().split()
cnt=0
F=deque()
for i in range(0,n-1):
    if S[i] in F:
        cnt+=0
    elif S[i] in T:
        cnt+=1
        F.append(S[i])
print(cnt)

Solution (Python):
n1=int(input())
a=list(map(int,input().split()))
n2=int(input())
b=list(map(int,input().split()))
cnt=0

for i in range(n2):
    for j in range(n1):
        if b[i]==a[j]:
            cnt+=1
            break


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

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

print(count)

Solution (Python):
n=int(input())
A=[]
A=input().split()
q=int(input())
B=[]
B=input().split()
count=0
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=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

cnt=0

for j in range(q):
    for i in range(n):
        v=S[i]
        w=T[j]
        if v==w:
            cnt=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(" ")))

count=0

for i in range(q):
    for j in range(n):
        
        if S[j]==T[i]:
            
            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
s.sort()
for i in range(n-1):
    if s[i]!=s[i+1]:
        for j in range(q):
            if s[i]==t[j]:
                cnt+=1
                break
if s[n-2]!=s[n-1]:
    for j in range(q):
        if s[n-1]==t[j]:
            cnt+=1
            break
print(cnt)

Solution (Python):
n=int(input())
s=input().split()
s.append(0)

q=int(input())
t=input().split()

cnt=0
for i in range(q):
    key=t[i]
    s[n]=key
    j=0
    while(s[j]!=key):
        j+=1

    if j==n:
        continue
    else:
        cnt+=1

print(cnt)

Solution (Python):
import math
def isPrime(s,t):
    cnt=0
    tmp=-1
    s.sort()
    t.sort()
    for i in s:
        if i!=tmp:
            for j in t:
                if i==j:
                    cnt=cnt+1
                    break;
        tmp=i
    return cnt
n=int(input())
s=list(map(int,input().split()))
q=int(input())
t=list(map(int,input().split()))
print(isPrime(s,t))

Solution (Python):
_ = input()
s = input().split()
_ = input()
t = input().split()

ans = 0
for ti in t:
    if ti in s:
        ans += 1
print(ans)

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

Solution (Python):
num1 = int(input())
arr1 = list(map(int,input().split()))

num2 = int(input())
arr2 = list(map(int,input().split()))

count = 0

for i in range(num2):
    try:
        a = arr1.index(arr2[i])
        count +=1
    except:
        pass

print(count)