Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
/* attention to typo and overflow */
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;
const int INF=1<<25;
void io(){ cin.tie(0);ios::sync_with_stdio(false);} //attention to use of endl
/*printf("%.9Lf\n",cf);*/
vector <int> s;
int solve(vector <int> a){
	if(a.size()!=s.size()) return INF;
	int n=a.size();
	int ret=0;
	for(int i=0;i<n;i++){
		ret+=abs(s[i]-a[i]);
	}
	return ret;
}

int main(){
	io();
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if(a==1){
			s.push_back(i);
		}
	}
	vector <int> obj;
	vector <int> obj2;
	int sum=0;
	for(int i=0;i<m;i++){
		if(i%2==0){
			int a;
			cin>>a;
			for(int j=sum;j<sum+a;j++){
				obj.push_back(j);
			}
			sum+=a;
		}else{
			int a;
			cin>>a;
			for(int j=sum;j<sum+a;j++){
				obj2.push_back(j);
			}
			sum+=a;
		}
	}

	/*for(int i=0;i<obj.size();i++){
		cerr<<obj[i]<<' ';
	}
	cerr<<endl;
	for(int i=0;i<obj2.size();i++){
		cerr<<obj2[i]<<' ';
	}
	cerr<<endl;*/

	cout<<min(solve(obj),solve(obj2))<<endl;


	return 0;
}