Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 20
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,m,ans,p[M];
vector<int> in,in2;
int calc()
{
	if(in.SZ != in2.SZ) return 100000;
	int re=0;
	REP(i,0,(int)in.SZ-1) re += abs(in[i] - in2[i]);
	return re;
}
int main()
{
	int x,pos;
	RI(n,m);
	REP(i,1,n)
	{
		RI(x);
		if(x) in.PB(i);
	}
	REP(i,1,m) RI(p[i]);

	x=0, pos=0;
	REP(i,1,m)
	{
		if(x==1) REP(j,pos+1,pos+p[i]) in2.PB(j);
		x ^= 1;
		pos += p[i];
	}
	ans = calc();

	in2.clear();
	x=1, pos=0;
	REP(i,1,m)
	{
		if(x==1) REP(j,pos+1,pos+p[i]) in2.PB(j);
		x ^= 1;
		pos += p[i];
	}
	ans = min(ans, calc());

	printf("%d\n",ans);
	return 0;
}