def linear
  n = gets.to_i
  a = gets.split(' ').map(&:to_i)
  m = gets.to_i
  b = gets.split(' ').map(&:to_i)
  count = 0
  for i in 0..a.size-1
    for j in 0..b.size-1
      if a[i] == a[j]
        count += 1
      end
    end
  end
  puts count
end

linear