(n,), s, (q,), t = $<.map {|s| s.split.map &:to_i }
s.sort!

# p t.count {|y| s.bsearch {|x| y <=> x } }

p t.count {|y|
  l, u = 0, n
  while l < u
    m = (l + u) / 2
    case y <=> s[m]
    when -1 then u = m
    when  0 then l = u = m
    when  1 then l = m + 1
    end
  end
  y == s[l]
}

