Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int calc(string s,string t){
	vector<int> p,q;
	rep(i,s.size())if(s[i]=='1')p.push_back(i);
	rep(i,t.size())if(t[i]=='1')q.push_back(i);
	if(p.size()!=q.size())return INF;
	int ans=0;
	rep(i,p.size()){
		ans+=abs(p[i]-q[i]);
	}
	return ans;
}
int main(){
	int n,m;
	string a,b;
	cin>>n>>m;
	rep(i,n){
		char c;
		cin>>c;
		a+=c;
	}
	rep(i,m){
		int p;
		cin>>p;
		rep(j,p){
			b+=i&1?'1':'0';
		}
	}
	int c=calc(a,b);
	rep(i,b.size())b[i]=b[i]=='1'?'0':'1';
	cout<<min(c,calc(a,b))<<endl;;
	return 0;
}