require 'benchmark'

n = gets.to_i
S = gets.split.map(&:to_i)
q = gets.to_i
T = gets.split.map(&:to_i)

Benchmark.measure do
  cnt = 0
  S.sort!
  T.each do |x|
    l = 0
    r = n
    while l < r
      m = (l + r) / 2
      if S[m] == x
        cnt += 1
        break
      elsif x < S[m]
        r = m
      else
        l = m + 1
      end
    end
  end
  puts cnt
end

