Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N,M;
int c[2];

int main(){
  cin >> N >> M;
  vector<int>ba(N), p(M);
  rep(i,N) cin >> ba[i];
  rep(i,M) cin >> p[i];
  rep(i,N) c[ba[i]]++;
  int sum=0;
  for(int i=0;i<M;i+=2) sum+=p[i];
  
  int res = INF;
  rep(loop,2){
    if(sum!=c[loop]) continue;
    int pat = loop;
    //    cout << "pat " << pat << endl;
    vector<int>b; b = ba;
    int cnt = 0;
    int pos = 0;
    rep(i,M){
      for(int j=0;j<p[i];j++){
	if(b[pos] != pat){
	  //	  cout << i << " " << j << endl;
	  int k = pos;
	  while(b[k]!=pat) k++;
	  for(int l=k;l>pos;l--){
	    swap(b[l], b[l-1]);
	    cnt++;
	  }
	}
	pos++;
	//	rep(j,N) cout << b[j] << " "; cout << endl;
      }
      pat ^= 1;
    }
    res = min(res, cnt);
  }
  cout << res << endl;  
  return 0;
}