
gets
array_1 = gets.chomp.split(" ").map(&:to_i)
gets
array_2 = gets.chomp.split(" ").map(&:to_i)

def binary_search(val, array)
  left = 0
  right = array.length
  array = array.sort

  while left < right do
    mid = (left+right) / 2
    if array[mid] == val
      return true
    elsif val < array[mid]
      right = mid
    else
      left = mid + 1
    end
  end
end

ans = 0
array_1.each do |val|
  if binary_search(val, array_2)
    ans += 1
  end
end

p ans