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 = set(map(int, input().split()))
q = int(input())
T = set(map(int, input().split()))

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

Solution (Python):
S_len = int(input().rstrip())
S = input().rstrip().split(" ")
T_len = int(input().rstrip())
T = input().rstrip().split(" ")

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

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

for num in T:
    if num 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 = 0
for num in t:
    if num in s:
        c += 1

print(c)

Solution (Python):
n = int(input())
S = set(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):
def main():
    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):
        if i == 0:
            if S[i] in T:
                cnt += 1
                continue
        if (S[i] in T) and (S[i] != S[i-1]):
            cnt += 1

    return cnt

print(main())

Solution (Python):
N1=int(input())
array1=input().split()
N2=int(input())
array2=input().split()
c=0
for n2 in range(N2):
    if array2[n2] in array1:
        c+=1
print(c)

Solution (Python):
if __name__ == '__main__':
  def linearSearch(t):
    S.append(t)
    
    i=0
    while S[i]!=t:
      i+=1
    del S[n]
    return 1 if i!=n else 0

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

  ans=0
  for t in T:
    ans+=linearSearch(t)
    
  print(ans)

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

S = list(set(S))

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

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

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

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

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

print(count)

Solution (Python):
import sys

n = int(sys.stdin.readline())
S = [int(x) for x in sys.stdin.readline().split()]
q = int(sys.stdin.readline())
T = [int(x) for x in sys.stdin.readline().split()]

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

C = 0

for i in S:
    if i in T:
        C += 1
        T.remove(i)
        
print(C)

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

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

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

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


resolve()

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):
from typing import Set, List


def linear_search_v1(S: List[int], key: int) -> int:
    for num in S:
        if num == key:
            return 1
    return 0


def linear_search_v2(S: List[int], key: int) -> int:
    i: int = 0
    S.append(key)

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

    if i != len(S) - 1:
        return 1
    else:
        return 0


def main_v1():
    _ = input()
    S: List[int] = list(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        
        count += linear_search_v2(S[:], num)

    print(count)


def main_v2():
    _ = input()
    S: Set[int] = set(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

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

    print(count)


if __name__ == "__main__":
    main_v2()

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

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

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

_ = int(input())
S = list(map(int,input().split()))
_ = int(input())
T = list(map(int,input().split()))
cnt = 0
for i in T:
    if i in S:
        cnt+=1
print(cnt)

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

cnt = 0
for t in T:
    S.append(t)
    i = 0
    while t != S[i]:
        i += 1
    if i != n:
        cnt += 1
    S.pop()

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

Solution (Python):
n = int(input())
S = list(map(int,input().split()))
p = 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 t in T:
    for s in S:
        if s == t:
            c += 1
            break
print(c)

Solution (Python):
from collections import deque

def linersearch(A,n,key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    if i == n:
        A.pop()
        return False
    else:
        A.pop()
        return True

n = int(input())
S = deque([int(x) for x in input().split()])
q = int(input())
T = [int(x) for x in input().split()]
ans = 0

for q in T:
    if linersearch(S,n,q):
        ans += 1

print(ans)

Solution (Python):
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    S = LI()
    q = I()
    T = LI()

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

if __name__ == '__main__':
    resolve()

Solution (Python):
import collections

def main():
  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)


if __name__ == '__main__':
  main()

Solution (Python):

N = int(input())
num_list = list(map(int, input().split()))
q = int(input())
search_num = list(map(int,input().split()))
ans = 0
for i in search_num:
    if i in num_list:
        ans += 1
print(ans)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n = int(input())
a = list(map(int,input().split()))
t = int(input())
u = list(map(int,input().split()))
cnt = 0
for i in range(len(u)):
    for j in range(len(a)):
        if a[j] == u[i]:
            cnt += 1
            break
print(cnt)

Solution (Python):
from sys import stdin

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

count = 0
for a in T:
    for b in S:
        if b == a:
            count += 1
            break

print(count)

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

Solution (Python):
n = int(input())
slist = list(map(int, input().split()))
q = int(input())
tlist = list(map(int, input().split()))

cnt = 0
for t in tlist:
    for s in slist:
        if t == s:
            cnt += 1
            break

print(cnt)

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

count = 0

for i in t:
    if i in s:
        count += 1
    else:
        continue

print(count)

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

if n>=q:
    for i in range(q):
        if T[i] in S:
            answer+=1

else:
    for i in range(n):
        if S[i] in T:
            answer+=1

print(answer)

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):
from collections import deque
import sys


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

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

    print(count)

Solution (Python):
def binary_search(a,n,key):
  left = 0
  right = n
  while left < right:
    mid = (left + right) // 2
    if a[mid] == key:
      return 1
    elif key < a[mid]:
      right = mid
    else:
      left = mid + 1
  return 0

n1 = int(input())
s1 = list(map(int,input().split()))
s1.sort()
n2 = int(input())
s2 = list(map(int,input().split()))
i = 0
cnt = 0
while i < n2:
  cnt += binary_search(s1,n1,s2[i])
  i += 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())
S = list(map(int, input().split()))

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

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

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


cnt = 0
for i in t:
	if s.count(i) !=0:
		cnt = cnt +1

print(cnt)

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

c = 0
for ti in t:
    if ti in s:
        c +=1

print(c)

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

print(len(s & t))

Solution (Python):




def linearSearch(target, data_list):
    for data in data_list:
        if target == data:
            return 1

    return 0


if __name__ == "__main__":
    n = int(input())
    S = [int(i) for i in input().split()]
    q = int(input())
    T = [int(j) for j in input().split()]

    total = 0

    for target in T:
        total += linearSearch(target, S)

    print(total)

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

print(ans)

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

def main(n,s,q,t):
    c = 0
    for j in t:
        for i in s:
            if(i == j):
                c += 1
                break

    return c

def main2(n,s,q,t):
    c=0
    for tj in t:
        s.append(tj)
        i=0
        while(s[i]!=tj):
            i+=1
        if(i<n):
            c+=1
        s.pop()
    return c

def main3(n,s,q,t):
    sets = set(s)
    sett = set(t)
    return (len((sets & sett)))

if __name__=='__main__':
    n,s,q,t = readinput()
    ans = main3(n,s,q,t)
    print(ans)

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

Solution (Python):
from typing import  Any, Sequence

def linerSearch(A: Sequence, K: int) -> int:
    global cnt
    N = len(S)
    for i in range(N):
        if A[i] == K:
            cnt += 1
    return  0



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

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

cnt = 0

for i in T:

    linerSearch(S, i)

print(cnt)

Solution (Python):
from sys import stdin

def linearSearch(target:list, value):
    target_copy = target.copy()
    target_copy.append(value)
    i = 0
    while target_copy[i] != value:
        i += 1
    if i == len(target_copy) - 1:
        return False
    return True

def main():
    n = stdin.readline()
    s = list(map(int, stdin.readline().split()))
    q = stdin.readline()
    t = list(map(int, stdin.readline().split()))
    print(sum([1 for v in t if linearSearch(s, v)]))
        
main()

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

i = 0
for tt in t:
  if tt in s:
    i += 1

print (i)

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

def Search(data, value):
    for i in range(len(data)):
           if data[i] == value:
               return i
    return -1
    
for j in range(q):
    if Search(S, T[j])  > -1:
        x.append(Search(S, T[j]))
print(len(x))

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


cnt = 0
for si in s:
    if si in t:
        cnt += 1

print(cnt)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
q = int(input())
l1 = list(map(int,input().split()))
s = 0
for i in l1:
  if i in l:
    s += 1
print(s)

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

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

cnt = 0
for t in T:
  idx = linearSearch(t)
  if idx != 'Not Found':
    cnt += 1
    
print(cnt)

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

count = 0
for s in S:
    if s in T:
        count += 1
        T.remove(s)

print(count)

Solution (Python):
n = int(input())
s = [int(_) for _ in input().split()]
q = int(input())
t = [int(_) for _ 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 = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

C = 0
for t in T:
    for s in S:
        if s == t:
            C = 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(q):
    for j in range(n):
        if t[i] == s[j]:
            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()))

def sentinel_linear_search(lst, value):
    idx = 0
    while lst[idx] != value:
        idx += 1
        if idx == len(lst)-1:
            return 0
    return 1

cnt = 0
for i in t:
    cnt += sentinel_linear_search(s, i)
print(cnt)

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

cnt = 0
for j in range(q):
    if T[j] in S:
        cnt += 1
        continue

print(str(cnt))

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

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

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

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

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

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

Solution (Python):



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

ctr = 0
for i in T:
    try:
        x = S.index(i)
        ctr += 1
    except:
        pass
        
print(ctr)

Solution (Python):
def linearSearch(A,key,i):
    c = 0
    A[i] = key
    while A[c] != key:
        c += 1
        if i == c:
            return 0
    return 1
    
n1 = int(input())
A = [int(e) for e in input().split()]
n2 = int(input())
B = [int(e) for e in input().split()]
A.append(0)
c = 0
for i in range(n2):
    c = c + linearSearch(A,B[i],len(A)-1)
print(c)

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

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

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

print(cnt)

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

cnt = 0
for t in T:
    if t 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(' ')))
r = 0


def linear_search(S, t):
    for s in S:
        if s == t:
            return True
    return False


for t in T:
    if linear_search(S, t):
        r += 1

print(r)

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

cnt = 0
for x in t:
    if x 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 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(" ")))

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

print(cnt)

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

    if i == len(l) - 1:
        return False
    else:
        return True

if __name__ == "__main__":
    import sys
    input = sys.stdin.readline 

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

    c = 0
    for key in T:
        if linear_search(S, key):
            c += 1

    print(c)

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

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

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


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

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

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

def linear_search(lst,key):
    i = 0
    while i<len(lst):
        if lst[i] == key:
            return 1
        else:
            i+=1
    return 0

ans = 0
for key in T:
    ans += linear_search(S,key)
print(ans)

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

s_max =  max(s)
q = int(input())
t = [int(i) for i in input().split() if int(i) <= max(s)]

c = 0

for i in range(n):
  if len(t) < 1: break
  if t == c: break

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

print(c)

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

    cnt = 0
    for y in b:
        for x in a:
           if y == x:
               cnt += 1
               break
    print(cnt) 

main()

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


def LinerSearch(A, key):
    for i in range(len(A)):
        if A[i] == key:
            return True

    return False


def LinerSearch2(A, key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    if i == n:
        A.pop()
        return False
    else:
        A.pop()
        return True



cnt = 0
for i in range(len(T)):
    if LinerSearch2(S, T[i]):
        cnt = 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 = list(set(list(map(int, input().split()))))
q = int(int(input()))
t = list(set(list(map(int, input().split()))))

ans = 0
for i in t:
    if i in s:
        ans += 1

print(ans)

Solution (Python):
from sys import stdin
n=list(map(int,(stdin.readline().strip().split())))
S =list(set(map(int,stdin.readline().strip().split())))
q=list(map(int,(stdin.readline().strip().split())))
T=list(map(int,stdin.readline().strip().split()))
S.sort(),T.sort()
count=0
c=-1

for t in T:
    SS=S
    while(True):
        n = len(SS)
        target = int((n - 1) / 2)
        if SS[target] ==t:
            count+=1
            break
        if SS[target] >t:
            SS=SS[:target]
        else:
            SS=SS[target:]
        if n==len(SS):
            if n==1:break
            if SS[1] == t or SS[0]==t:
                count += 1
                break
            break


print(count)

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

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

def linear_search(S, T):
    num = 0
    for target_num in T:
        for s_item in S:
            if target_num == s_item:
                num += 1
                break
    return num


print(linear_search(S, T))

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

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

n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]
C = 0
for t in T:
    if linearSearch(S, 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(' ')))

def linearSearch(key):
  i = 0
  len_pre_S = len(S)
  S.append(key)
  while S[i] != key:
    i += 1
  if i == len_pre_S:
    return 0
  return 1

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

Solution (Python):

def main():
    n = int(input())
    a = list(map(int,input().split()))
    m = int(input())
    b = list(map(int,input().split()))
    res = 0
    for i in range(m):
        for j in range(n):
            if b[i]==a[j]:
                res+=1
                break
    print (res)


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

Solution (Python):



import sys
from collections import deque

def input_lines():
    return sys.stdin.readlines()

def liner_search(lines):
    s = sorted(map(int, lines[1].split()))
    t = deque(sorted(map(int, lines[3].split())))
    
    idx, count = 0, 0
    while len(t) > 0:
        nt = t.popleft()
        found = False
        while idx < len(s):
            if nt == s[idx]:
                found = True
                break
            else:
                idx += 1
        if found:
            count += 1
        else:
            idx = 0
        
    return count
lines = input_lines()
print(liner_search(lines))

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

count =set()

for i in range(Q):
    for j in range(N):
        if T[i]==S[j]:
            count.add(T[i])
if len(count)>0:
    print(len(count))
    
else:
    print("0")

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):
    q_temp = T[i]
    S.append(q_temp)
    j = 0
    while S[j] != q_temp:
        j += 1
    if j < n:
        ans += 1

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

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

Solution (Python):
n = input()
S = list(map(int,input().split()))
q = input()
T = list(map(int,input().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())) + [0]
q = int(input())
T = map(int,input().split())
ret = 0
for t in T:
  i = 0
  S[n] = t
  while t != S[i]:
    i += 1
  if i != n:
    ret += 1
print(ret)

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

Solution (Python):


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

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


main()

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

c = 0

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

S.append(0)

def func(x):
  S[n] = T[x] 
  i = 0
  while S[i] != S[n]:
    i += 1
    if i==n:
      return 0
  return 1

C = 0
for i in range(q):
  C += func(i)

print(C)

Solution (Python):
def main():
    input()
    S = set(map(int, input().split(' ')))
    input()
    T = map(int, 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 = list(input().split())
q = int(input())
T = list(input().split())
S.append(-1)
Sum = 0 

for i in range(len(T)):
    S[n] = T[i] 
    t = 0
    while(S[t] != S[n]):
        t += 1
    if t == n:
        continue
    else:
        Sum += 1
print(Sum)

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

Solution (Python):
def linear_search(A, key):
    N = len(A)
    A[N - 1] = key
    i = 0
    while A[i] != key:
        i += 1
    return i != (N - 1)

if __name__ == "__main__":
    N = int(input())
    num_list = list(map(int, input().split()))
    M = int(input())
    target_list = list(map(int, input().split()))

    count = 0
    for target in target_list:
        if(linear_search(num_list, target)):
            count += 1
    print(count)

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

c = 0
addedOnce = False
for t in T:
    addedOnce = False
    for s in S:
        if t == s and not addedOnce:
            c += 1
            addedOnce = True
print(c)

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

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

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

ans = 0
for i in range(int(n)):
    if s[i] in s[:i]:
        continue
    if s[i] in t:
        ans += 1
print(ans)

Solution (Python):
def solv(S, T):
    tset = set(T)
    count = 0
    for s in S:
        if s in T:
            count += 1
            T.remove(s)
    return count


if __name__ == "__main__":

    _ = input()
    S = input().split()
    _ = input()
    T = input().split()

    ans = solv(S, T)

    print(ans)