both = {'a', 'A', 'b', 'B'}
some = {'a', 'b', 'c'}
result1 = both & some
# result: {'a', 'b'}
result2 = both.intersection(some)
print(result1 == result2)
# True
# The intersection() function can be used to create a new set containing the shared
# values from one set with another
mySet = {1, 2, 3, 4}
mySet2 = {3, 4, 5, 6}
mySet3 = mySet.intersection(mySet2)
print(mySet3)
# Output:
# {3, 4}
firstSet = {2, 3, 4, 5}
secondSet = {1, 3, 5, 7}
print(firstSet & secondSet)
# {3, 5}
# Enter your code here. Read input from STDIN. Print output to STDOUT
num1, st1, num2, st2 = (set(input().split()) for i in range(4))
print(len(st1.intersection(st2)))