gets
a = gets.split(' ').map(&:to_i)
gets
b = gets.split(' ').map(&:to_i)
def bi(a, b)
  cnt = 0
  b.each do |key|
    left = 0
    right = a.length-1
    while left < right
      mid = (left + right) / 2
      if a[mid] == key
        cnt += 1
        break
      elsif a[mid] < key
        left = mid + 1
      else
        right = mid - 1
      end
    end
  end
  cnt
end

puts bi(a, b)