### constant

INF = 1 << 30

### main

n, m = gets.split.map(&:to_i)

bs = gets.split.map(&:to_i)
st = bs.join.to_i(2)
#puts st

rls = gets.split.map(&:to_i)

b = 0
bits = 0
k = n - 1
for i in (0...m)
  for j in (0...rls[i])
    bits |= 1 << k if b == 1
    k -= 1
  end
  b ^= 1
end

gl0 = bits
gl1 = ((1 << n) - 1) ^ bits
#p [gl0, gl1]

swaps = []
mask = 3
for i in (1...n)
  swaps << mask
  mask <<= 1
end
#p swaps.map{|b| b.to_s(2)}

dists = Array.new(1 << n){INF}
dists[st] = 0

q = [st]

while ! q.empty?
  u = q.shift
  break if u == gl0 || u == gl1

  for mask in swaps
    um = u & mask
    next if um == 0 || um == mask
    v = u ^ mask
    if dists[v] >= INF
      dists[v] = dists[u] + 1
      q << v
    end
  end
end

puts [dists[gl0], dists[gl1]].min