Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vi s;
	rep(i,n){
		int a;cin>>a;
		if(a)s.pb(i);
	}
	vi in(n);
	int t=0;
	rep(i,m){
		int a;cin>>a;
		if(i%2)rep(j,a)in[t+j]=1;
		t+=a;
	}
	int out=inf;
	rep(i,2){
		vi w;
		rep(j,n)if(in[j]==i)w.pb(j);
		if(w.size()!=s.size())continue;
		int sum=0;
		rep(j,w.size())sum+=abs(w[j]-s[j]);
		out=min(sum,out);
	}
	cout<<out<<endl;
}