Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#include <iostream>
#include <algorithm>
using namespace std;

int N, M;
int B[20], Pt[20], P[20];

void read();
void solve();

int main() {
  read();
  solve();
  return 0;
}

void read() {
  cin >> N >> M;
  for (int i = 0; i < N; ++i)
    cin >> B[i];

  for (int i = 0; i < M; ++i)
    cin >> Pt[i];
}

void solve() {
  int q, res = 100, tmp;

  q = 0;
  for (int i = 0, k = 0; i < M; ++i, q = 1 - q)
    for (int j = 0; j < Pt[i]; ++j)
      P[k++] = q;

  tmp = 0;
  for (int i = 0; i < N; ++i)
    if (B[i] != P[i]) {
      for (int j = i + 1; j < N; ++j) {
        ++tmp;
        if (B[i] == P[j]) {
          swap(P[i], P[j]);
          break;
        }
      }

      if (B[i] != P[i]) {
        tmp = 100;
        break;
      }
    }

  res = min(res, tmp);

  q = 1;
  for (int i = 0, k = 0; i < M; ++i, q = 1 - q)
    for (int j = 0; j < Pt[i]; ++j)
      P[k++] = q;

  tmp = 0;
  for (int i = 0; i < N; ++i)
    if (B[i] != P[i]) {
      for (int j = i + 1; j < N; ++j) {
        ++tmp;
        if (B[i] == P[j]) {
          swap(P[i], P[j]);
          break;
        }
      }

      if (B[i] != P[i]) {
        tmp = 100;
        break;
      }
    }

  res = min(res, tmp);

  cout << res << "\n";
}