def SearchEqual(s, t)
	matched = []
	for i in 0..s.length-1
		for j in 0..t.length-1
			if s[i] == t[j]
				matched << t[j]
			end
		end
	end
	matched = matched.uniq
	p matched.length
end

#input sequence of numbers S
n = gets.chomp
n = gets.chomp
n = n.split()
#input of sequence of numbers T
q = gets.chomp
q = gets.chomp
q = q.split()
#output
SearchEqual(n, q);