Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
N, M = map(int, input().split())
*B, = map(int, input().split())
*P, = map(int, input().split())
def solve(v):
    C = B[:]
    D = []
    for i in range(M):
        D += [(i & 1) ^ v]*P[i]
    res = 0
    for i in range(N):
        if C[i] != D[i]:
            for j in range(i, N):
                if D[i] == C[j]:
                    C[i], C[j] = C[j], C[i]
                    res += j - i
                    break
            else:
                return 10**9
    return res
print(min(solve(0), solve(1)))