def lin(a,b)
  i = 0
  count = 0
  b.each do |key|
    a[a.size] = key
    while a[i] != key
      i += 1
    end
    if i == key
      count += 1
    end
  end
  count
end
gets
a=gets.split(' ').map(&:to_i)
gets
b=gets.split(' ').map(&:to_i)
puts lin(a,b)