Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
int a[22],p[22];
int a1[22],a2[22];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>p[i];
	rep(i,m)p[i+1]+=p[i];
	int a11=1,a22=0,l=0;
	rep(i,n){
		if(l<m&&i==p[l])l++,swap(a11,a22);
		a1[i]=a11;
		a2[i]=a22;
	}
	int cnt=0,cnt1=0,cnt2=0;
	rep(i,n){
		if(a[i])cnt++;
		if(a1[i])cnt1++;
		if(a2[i])cnt2++;
	}
	int res=INF;
	if(cnt==cnt1){
		int sum=0,l=0;
		rep(i,n){
			if(a[i]){
				while(a1[l]==0)l++;
				sum+=abs(i-l);
				l++;
			}
		}
		minch(res,sum);
	}
	if(cnt==cnt2){
		int sum=0,l=0;
		rep(i,n){
			if(a[i]){
				while(!a2[l])l++;
				sum+=abs(i-l);
				l++;
			}
		}
		minch(res,sum);
	}
	cout<<res<<endl;
	return 0;
}