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

if __name__ == '__main__':
	linear_search() def linear_search():
	input()
	s = set(input().split())
	input()
	t = set(input().split())
	print(len(s & t))	 linear_search input() input s = set(input().split()) s set(input().split()) set input().split() ().split () input split input() input t = set(input().split()) t set(input().split()) set input().split() ().split () input split print(len(s & t)) print len(s & t) len s & t s t if __name__ == '__main__':
	linear_search() __name__ == '__main__' __name__ '__main__' linear_search() linear_search def linear_search():
	input()
	s = set(input().split())
	input()
	t = set(input().split())
	print(len(s & t))	 def linear_search():
	input()
	s = set(input().split())
	input()
	t = set(input().split())
	print(len(s & t))	 linear_search
def linear_search():
	input()
	s = set(input().split())
	input()
	t = set(input().split())
	print(len(s & t))	

if __name__ == '__main__':
	linear_search()