loop do
  n = gets.to_i
  break if n == 0

  arr = gets.split(' ').map(&:to_i)
  _q = gets.to_i
  q_arr = gets.split(' ').map(&:to_i)

  count = 0
  q_arr.each do |a|
    count += 1 if arr.include?(a)
  end
  puts count
end