Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

vector<int> f(vector<int> v, int val) {
	vector<int> res;
	REP(i, v.size()) {
		REP(j, v[i]) {
			res.pb(i % 2 == 0 ? val : !val);
		}
	}
	return res;
}
int cnt1(vector<int> a) {
	int res = 0;
	REP(i, a.size()) {
		if (a[i] == 1) ++res;
	}
	return res;
}
int solve(vector<int> a, vector<int> b) {
	int n = a.size();
	vector<int> A, B;
	if ( cnt1(a) != cnt1(b) ) return inf;
	REP(i, n) {
		if (a[i] == 1) {
			A.pb(i);
		}
	}
	REP(i, n) {
		if (b[i] == 1) {
			B.pb(i);
		}
	}
	int res = 0;
	REP(i, A.size()) {
		res += abs(A[i] - B[i]);
	}
	return res;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M; cin >> N >> M;
	vector<int> v(N); cin >> v;
	vector<int> to(M); cin >> to;
	int ans = min( solve(v, f(to, 0)), solve(v, f(to, 1)) );
	cout << ans << endl;
}