loop {
  n, m = gets.split.map{|i| i.to_i}
  break if n | m == 0

  h = Array.new
  for i in 1 .. n
    h << gets.chomp.to_i
  end

  w = Array.new
  for i in 1 .. m
    w << gets.chomp.to_i
  end

  ans = 0
  for i in 0 ... n
    y = 0
    for j in i ... n
      y += h[j]
      for k in 0 ... m
        x = 0 
        for l in k ... m
          x += w[l]
          if x == y
            ans += 1
            break
          elsif x > y
            break
          end
        end
      end
    end
  end

  puts ans
}