gets
s=gets.split.map(&:to_i)
gets
t=gets.split.map(&:to_i)

# Array#bsearch
#p t.count{|n|s.bsearch{|m| m >= n} == n}

def bsearch(arr, n)
  return false if arr.empty?

  start_pos = 0
  end_pos = arr.length - 1

  while start_pos <= end_pos
    i = (end_pos + start_pos) / 2
    elem = arr[i]

    break if n == elem
    
    if n < elem
      end_pos = i - 1
    else
      start_pos = i + 1
    end
  end

  return elem == n
end

p t.count{|n| bsearch(s,n)}

