Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** Problem1345 : Bit String Reordering**/
int main()
{
	int N, M;
	cin>>N>>M;
	vector<int> target(N), r(M);
	rep(i, N) cin>>target[i];
	rep(i, M) cin>>r[i];

	int tZero = 0;
	for (int i=0; i<N; i++)
		if (target[i]==0) tZero++;
	
	int ans=INF;
	for (int k=0; k<2; k++) {
		vector<int> R(N);
		
		int idx=0, nZero=0;
		bool tone=k;
		for (int i=0; i<M; i++) {
			for (int j=0; j<r[i]; j++) {
				R[idx++] = tone;
				if (!tone) nZero++;
			}
			tone = !tone;
		}
		
		if (tZero != nZero) continue;
		
		int tans = 0;
		for (int i=0; i<N; i++) {
			if (target[i] != R[i]) {
				for (int j=i+1; j<N; j++) {
					if (target[i] == R[j]) {
						for (int jj=j; jj>=i+1; jj--) {
							swap(R[jj-1], R[jj]);
							tans++;
						}
						break;
					}
				}
			}
		}
		ans = min(ans, tans);
	}
	
	cout << ans << endl;
}