inputa = list(map(int, input().split()))
inputb = list(map(int, input().split()))
inputc = list(map(int, input().split()))

seta = set(inputb) & set(inputc)

countb = []
countc = []
result = 0
for i in seta:
  countb.append(inputb.count(i))
  countc.append(inputc.count(i))
for i in range(len(countb)):
  for j in range(i)
  result += countb[i] * countc[j]

print(result)