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 ≤ 109

0 ≤ an element in T ≤ 109

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

Template in C
-->



Sample input:
5
1 2 3 4 5
3
3 4 1


Sample output:
3

Submission status: Accepted

Solution code:
#coding:UTF-8
def LS(n,S,q,T):
    count=0
    if n>q:
        for i in range(q):
            if T[i] in S:
                count+=1
    else:
        for i in range(n):
            if S[i] in T:
                count+=1
    print(count)
  
if __name__=="__main__":
    n=int(input())
    S=input().split(" ")
    q=int(input())
    T=input().split(" ")
    LS(n,S,q,T)

Submission status: Accepted

Solution code:
# encoding: utf-8


class Solution:
    @staticmethod
    def linear_search():
        array_length_1 = int(input())
        array_1 = [int(x) for x in input().split()]
        array_length_2 = int(input())
        array_2 = [int(x) for x in input().split()]

        print(len(list(set(array_1).intersection(set(array_2)))))


if __name__ == '__main__':
    solution = Solution()
    solution.linear_search()

Submission status: Accepted

Solution code:
# encoding: utf-8


class Solution:
    @staticmethod
    def linear_search():
        array_length_1 = int(input())
        array_1 = [int(x) for x in input().split()]
        array_length_2 = int(input())
        array_2 = [int(x) for x in input().split()]

        print(len(set(array_1).intersection(set(array_2))))


if __name__ == '__main__':
    solution = Solution()
    solution.linear_search()

Submission status: Accepted

Solution code:
# encoding: utf-8
 
 
class Solution:
    @staticmethod
    def linear_search():
        array_length_1 = int(input())
        array_1 = [int(x) for x in input().split()]
        array_length_2 = int(input())
        array_2 = [int(x) for x in input().split()]
 
        print(len(set(array_1).intersection(set(array_2))))
 
 
if __name__ == '__main__':
    solution = Solution()
    solution.linear_search()

Submission status: Accepted

Solution code:
# encoding: utf-8


class Solution:
    @staticmethod
    def linear_search():
        array_length_1 = int(input())
        array_1 = [int(x) for x in input().split()]
        array_length_2 = int(input())
        array_2 = [int(x) for x in input().split()]

        # print(len(set(array_1).intersection(set(array_2))))
        count = 0
        for i in range(array_length_2):
            if array_2[i] in array_1:
                count += 1
        print(count)


if __name__ == '__main__':
    solution = Solution()
    solution.linear_search()

Submission status: Accepted

Solution code:
# encoding: utf-8


import sys


class Solution:
    def __init__(self):
        """
        init input array
        """
        self.__input = sys.stdin.readlines()

    @property
    def solution(self):
        length_1 = int(self.__input[0])
        array_1 = list(map(int, self.__input[1].split()))
        length_2 = int(self.__input[2])
        array_2 = list(map(int, self.__input[3].split()))

        assert length_1 == len(array_1) and length_2 == len(array_2)

        count = 0
        for each in array_2:
            if self.linear_search(key=each, array=array_1, array_length=length_1):
                count += 1

        return str(count)

    @staticmethod
    def linear_search(key, array, array_length):
        # print(len(set(array_1).intersection(set(array_2))))
        for i in range(array_length):
            if array[i] == key:
                return True
        return False


if __name__ == '__main__':
    case = Solution()
    print(case.solution)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
#-*- coding:utf-8 -*-

def linearSearch(arr,key):
	arr.append(int(key))
	for idx,a in enumerate(arr):
		if a == key:
			if idx == (len(arr) - 1):
				return -1
			else :
				return 1
	
def main():
	Ns = int(raw_input())
	S  = map(int, raw_input().split())
	Nt = int(raw_input())
	T  = map(int, raw_input().split())

	sum_v = 0
	for key  in T:
		if linearSearch(S,key) > 0:
			sum_v += 1

	print sum_v

#def test():

if __name__ == '__main__':
	main()
	#test()

Submission status: Accepted

Solution code:
#http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_4_A
#?????¢??¢?´¢
#???????????§?¨????????????????????????¨?????§??????????????\????????????????????????????????????
def linear_search(list_1, list_2):
    count = 0
    
    for a in list_1:
        i = 0
        list_2.append(a)
        while not a == list_2[i]:
            i += 1
        if not i == len(list_2) - 1:
            count += 1
            
        list_2 = list_2[:-1]
        
    return count

def main():
    n_listA = int(input())
    a = list(set([n for n in input().split()]))
    n_listB = int(input())
    b = list(set([n for n in input().split()]))
    print(linear_search(a,b))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    # ??????????????\???
    S_size = int(input())
    S = set([int(x) for x in input().split(' ')])
    T_size = int(input())
    T = set([int(x) for x in input().split(' ')])
    # S = [1, 2, 3, 4, 5, 1]
    # T = set([3, 4, 1])

    # ????????????
    U = S.intersection(T)

    # ???????????????
    print('{0}'.format(len(U)))

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ?????¢??¢?´¢ '''

# n??????????´??????????????????????q????????¢?´¢????????£?????´???
# ?¨??????????O(qn)


def linear_search(S, T):
    count = 0
    for t in T:
        if t in S:
            count += 1
    return count

if __name__ == '__main__':
    NS = int(input())
    S = list(map(int, input().split()))
    NT = int(input())
    T = list(map(int, input().split()))

    print(linear_search(S, T))

Submission status: Accepted

Solution code:
n = int(input())
S = [x for x in input().split()]
q = int(input())
T = [x for x in input().split()]
answer = {x for x in S if x in T}
print(len(answer))

Submission status: Accepted

Solution code:
# coding: utf-8
# input
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)

Submission status: Accepted

Solution code:
# coding: utf-8
input()
s = list(map(int,input().split()))
input()
t = list(map(int,input().split()))
cnt = 0
for i in t:
    if i in s:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
# linearSearch
def linear(n,s,key):
    s[n:] = [key]
    i = 0
    while s[i] != key:
        i += 1
    return i != n
n = int(input())
s = list(map(int,input().split()))
input()
t = list(map(int,input().split()))
cnt = 0
for i in t:
    if linear(n,s,i):
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:

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

ans=len(set(s)&set(t))

print(ans)

Submission status: Accepted

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


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

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

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

print(cnt)

Submission status: Accepted

Solution code:

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

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

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

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

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

cnt = 0

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

print(cnt)

Submission status: Accepted

Solution code:

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

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

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

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

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

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

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

print(ans)

Submission status: Accepted

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

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

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

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


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

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

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

print(ans)

Submission status: Accepted

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

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


print(count)

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

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

linearSearch(n, S, q, T)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

#fin = open("test.txt", "r")
fin = sys.stdin

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

ret = 0

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

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

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

    print counter 

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

    print len(s.intersection(t))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

    print len(s & t)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def linear_search(value, target_list):
    for key in target_list:
        if value == key:
            return True
    return False


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


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

    print counter

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

tCount = 0


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

print(tCount)

Submission status: Accepted

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

print(cont)

Submission status: Accepted

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

print(len(s & t))

Submission status: Accepted

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


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

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

    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

seq_Both = seq_S & seq_T

print(len(seq_Both))

Submission status: Accepted

Solution code:
# encording: utf-8

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


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


print(main(ns, qs))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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


res = 0

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

print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os


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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

findCount = 0

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

print(findCount)

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

if __name__ == '__main__':
	linear_search()

Submission status: Accepted

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

Submission status: Accepted

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

print(str(cnt))

Submission status: Accepted

Solution code:
# coding=utf-8

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

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

print(counter)

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding:utf-8 -*-

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
	num = 0

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

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

if __name__ == '__main__':
	main()

Submission status: Accepted

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

cnt = 0

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

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Linear Search
n ????????´??°???????????°??? S ??¨???q ????????°????????´??°???????????°??? T ??????????????????
T ?????????????????´??°????????§ S ?????????????????????????????° C ???????????????????????°????????????????????????????????????
"""

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

C=0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print count

Submission status: Accepted

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

sum = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Aizu Problem ALDS_1_4_A: Linear Search
#
import sys, math, os

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


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

Submission status: Accepted

Solution code:
import sys

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

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

res = []

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

ans = 0

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

print ans

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

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

print(len(s & t))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import sys


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


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

Submission status: Accepted

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


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

    print(linearSearch(s, t))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print cnt

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Sum = 0

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

Submission status: Accepted

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

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

    print(cnt)

main()