#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
using namespace std;

//7:10
//
//#define REP(i,n) for(int i=0;i<(int)n;++i)
//#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
//#define ALL(c) (c).begin(), (c).end()
//
//typedef int Weight;
//struct Edge {
//	int src, dst;
//	Weight weight;
//	Edge(int src, int dst, Weight weight) :
//		src(src), dst(dst), weight(weight) { }
//};
//bool operator < (const Edge &e, const Edge &f) {
//	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
//	e.src != f.src ? e.src < f.src : e.dst < f.dst;
//}
//typedef vector<Edge> Edges;
//typedef vector<Edges> Graph;
//
//typedef vector<Weight> Array;
//typedef vector<Array> Matrix;
//
//#define RESIDUE(s,t) (capacity[s][t]-flow[s][t])
//Weight maximumFlow(const Graph &g, int s, int t) {
//	int n = g.size();
//	Matrix flow(n, Array(n)), capacity(n, Array(n));
//	REP(u, n) for (auto e = g[u].begin(); e != g[u].end();++e)capacity[e->src][e->dst] += e->weight;
//
//	Weight total = 0;
//	while (1) {
//		queue<int> Q; Q.push(s);
//		vector<int> prev(n, -1); prev[s] = s;
//		while (!Q.empty() && prev[t] < 0) {
//			int u = Q.front(); Q.pop();
//			for (auto e = g[u].begin(); e != g[u].end(); ++e) if (prev[e->dst] < 0 && RESIDUE(u, e->dst) > 0) {
//				prev[e->dst] = u;
//				Q.push(e->dst);
//			}
//		}
//		if (prev[t] < 0) return total; // prev[x] == -1 <=> t-side
//		Weight inc = 999999999;
//		for (int j = t; prev[j] != j; j = prev[j])
//			inc = min(inc, RESIDUE(prev[j], j));
//		for (int j = t; prev[j] != j; j = prev[j])
//			flow[prev[j]][j] += inc, flow[j][prev[j]] -= inc;
//		total += inc;
//	}
//	return total;
//}
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()


const int mod = 1000000007;

struct Mod {
	long long int num;
	Mod() : num(0) { ; }
	Mod(long long int n) : num((n % mod + mod) % mod) { ; }
	operator long long int() { return num; }
};

Mod operator+(Mod a, Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator-(Mod a, Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator*(Mod a, Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator+=(Mod &a, Mod b) { return a = a + b; }
Mod operator-=(Mod &a, Mod b) { return a = a - b; }
Mod operator*=(Mod &a, Mod b) { return a = a * b; }
Mod operator^(Mod a, int n) {
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod inv(Mod a) { return a ^ (mod - 2); }
Mod operator/(Mod a, Mod b) { return a * inv(b); }

#define MAX_N 1024000

Mod fact[MAX_N], factinv[MAX_N];
void init() {
	fact[0] = Mod(1); factinv[0] = 1;
	REP(i, MAX_N - 1) {
		fact[i + 1] = fact[i] * Mod(i + 1);
		factinv[i + 1] = factinv[i] / Mod(i + 1);
	}
}
Mod comb(int a, int b) {
	return fact[a] * factinv[b] * factinv[a - b];
}

long long int memo[20];//nけた

long long int powint(long long int a, int b){
	if (b == 0)return 1;
	if (b == 1)return a;
	else{
		long long int ans = 1;
		long long int c = powint(a, b / 2);
		ans *= c*c;
		ans *= (b % 2) ? a : 1;
		return ans;
	}

}


int backnum[100000][20];

struct Node{
	Node(int aid):children(),ancs(){
		id=(aid);
		for (int i = 0; i < 20; ++i){
			ancs[i] = -1;
		}
	}
	int id;
	vector<int>children;
	array<int, 20>ancs;
};

int main()
{
	int N,M;
	cin >> N >> M;
	bitset<15>Moto;
	for (int i = 0; i < N; ++i){
		int a;
		cin >> a;
		Moto[i]=a;
	}
	vector<int>k;
	
	for (int i = 0; i < M; ++i){
		int a;
		cin >> a;
		k.emplace_back(a);
	}
	int ans = 9999;
	{
		int a = 1;
		bitset<15> Next1;
		int count = 0;
		for (int i = 0; i < k.size(); ++i){
			for (int j = 0; j < k[i]; ++j){
				Next1[count++] = a;
				
			}
			if (a)a = 0;
			else a = 1;
		}
		if (Moto.count() != Next1.count()){
			
		}
		else{
			vector<int>oneplace;
			vector<int>oneplace2;
			for (int i = 0; i < N; ++i){
				if (Moto[i])oneplace.push_back(i);
				if (Next1[i])oneplace2.push_back(i);
			}
			if (!oneplace.size()){
				ans = 0;
			}
			else{
				int kotae = 0;
				int mit = oneplace[0];
				int nit = oneplace2[0];
				kotae += abs(mit - nit);
				for (int i = 1; i < oneplace.size(); ++i){
					kotae += abs(oneplace[i] - oneplace2[i]);
				}
				ans = min(ans, kotae);
			}
		}
	}
	{
		int a =0;
		bitset<15> Next1;
		int count = 0;
		for (int i = 0; i < k.size(); ++i){
			for (int j = 0; j < k[i]; ++j){
				Next1[count++] = a;

			}
			if (a)a = 0;
			else a = 1;
		}
		if (Moto.count() != Next1.count()){

		}
		else{
			vector<int>oneplace;
			vector<int>oneplace2;
			for (int i = 0; i < N; ++i){
				if (Moto[i])oneplace.push_back(i);
				if (Next1[i])oneplace2.push_back(i);
			}
			if (!oneplace.size()){
				ans = 0;
			}
			else{
				int kotae = 0;
				int mit = oneplace[0];
				int nit = oneplace2[0];
				kotae += abs(mit - nit);
				for (int i = 1; i < oneplace.size(); ++i){
					kotae += abs(oneplace[i] - oneplace2[i]);
				}
				ans = min(ans, kotae);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19172