def binary_search(arr, search)
  n = (arr.size/2.0).floor
  if arr[n] == search
    return arr[n]
  elsif arr[n] > search
    binary_search(arr[(n+1)..-1], search)
  else
    binary_search(arr[0..(n-1)], search)
  end
end

loop do
  n = gets.to_i
  break if n == 0
  arr = gets.split(' ').map(&:to_i)
  _q = gets.to_i
  search_arr = gets.split(' ').map(&:to_i)

  count = 0
  search_arr.each do |search|
    count += 1 if binary_search(arr, search)
  end

  puts count
end