def bsearch(a, c)
  return false if a.empty? || a.nil?

  len = a.length
  if len == 1
    a[0] == c
  else
    mid = len/2
    case
    when a[mid] == c
      true
    when a[mid] > c
      bsearch(a[0..(mid-1)], c)
    when a[mid] < c
      bsearch(a[(mid+1)..-1], c)
    end
  end
end

gets
s = gets.split.map(&:to_i)
gets
t = gets.split.map(&:to_i)
sum = 0
t.each do |c|
  sum += 1 if bsearch(s, c)
end
puts sum

