
gets
S_ARRAY = gets.chomp.split(" ").map(&:to_i).sort
gets
T_ARRAY = gets.chomp.split(" ").map(&:to_i).sort

def binary_search(val)
  left = 0
  right = S_ARRAY.count
  while left < right do
    mid = (left + right) / 2
    if S_ARRAY[mid] == val
      return true
    elsif val < S_ARRAY[mid]
      right = mid
    else # val < S_ARRAY[mid]
      left = mid + 1
    end
  end
end

ans = 0
T_ARRAY.each do |val|
  if binary_search(val)
    ans += 1
  end
end

p ans