Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 15;
const int MAX_M = 15;

const int INF = 1 << 30;

/* typedef */

/* global variables */

int bs[MAX_N], ps[MAX_M], as[MAX_N], gs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  cin >> n >> m;

  int zn = 0;
  for (int i = 0; i < n; i++) {
    cin >> bs[i];
    if (bs[i] == 0) zn++;
  }
  for (int i = 0; i < m; i++) cin >> ps[i];

  int ans = INF;
  
  for (int ib = 0; ib <= 1; ib++) {
    for (int i = 0; i < n; i++) as[i] = bs[i];

    int gzn = 0;
    for (int i = 0, k = 0, b = ib; i < m; i++, b ^= 1) {
      for (int j = 0; j < ps[i]; j++) gs[k++] = b;
      if (b == 0) gzn += ps[i];
    }
    if (zn != gzn) continue;

    //for (int i = 0; i < n; i++) printf("%d", bs[i]); putchar('\n');
    //for (int i = 0; i < n; i++) printf("%d", gs[i]); putchar('\n');

    int cnt = 0;
    for (int i = 0; i < n; i++)
      if (as[i] != gs[i]) {
	int k = i + 1;
	while (as[k] != gs[i]) k++;
	for (int j = k; j > i; j--) swap(as[j - 1], as[j]), cnt++;
      }
    if (ans > cnt) ans = cnt;
  }

  printf("%d\n", ans);
  return 0;
}