Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
int main() {
    int n, m; cin >> n >> m;
	int b[15];int p[15]; vector<int>s;
	rep(i, n) {
		cin >> b[i];
		if (b[i])s.push_back(i);
	}
	rep(i, m) {
		cin >> p[i];
	}
	int now = 0; bool f = false;
	vector<int>t,u;
	rep(i, m) {
		rep(j, p[i]) {
			if (f) {
				t.push_back(now);
			}
			else {
				u.push_back(now);
			}
			now++;
		}
		if (f)f = false;
		else f = true;
	}
	int mi = 10000; int len = s.size();
	if (len==(int)t.size()) {
		int sum = 0;
		rep(i, len) {
			sum += abs(s[i] - t[i]);
		}
		mi = min(mi, sum);
	}
	if (len==(int)u.size()) {
		int sum = 0;
		rep(i, len) {
			sum += abs(s[i] - u[i]);
		}
		mi = min(mi, sum);
	}
	cout << mi << endl;
	return 0;
}
