Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;

int main() {

  int n, m;
  cin >> n >> m;

  vector<int> org(n, 0);
  int tmpx = 0;
  int cnt  = 0;

  rep (i, n) {
    cin >> tmpx;
    cnt += tmpx;
    org[i] = tmpx;
  }

  vector<int> tmp(m, 0);
  rep (i, m) cin >> tmp[i];

  vector<int> goal1(n, 0);
  vector<int> goal2(n, 0);

  int x = 0;
  int tmpi = 0;

  int cnt1 = 0;
  int cnt2 = 0;

  rep (i, m) {
    x = (x + 1) % 2;
    rep (j, tmp[i]) {
      goal1[tmpi] = x;
      cnt1 += x;
      goal2[tmpi] = (x + 1) % 2;
      cnt2 += (x + 1) % 2;
      tmpi += 1;
    }
  }

  int ans1 = 0;
  int ans2 = 0;

  tmpi = 0;
  rep (i, n) {
    if (cnt != cnt1) {
      ans1 = 1000;
      break;
    }
    if (org[i] == 1) {
      while (goal1[tmpi] == 0) {
        tmpi += 1;
      }
      ans1 += abs(tmpi - i);
      tmpi += 1;
    }
  }

  tmpi = 0;
  rep (i, n) {
    if (cnt != cnt2) {
      ans2 = 1000;
      break;
    }
    if (org[i] == 1) {
      while (goal2[tmpi] == 0) {
        tmpi += 1;
      }
      ans2 += abs(tmpi - i);
      tmpi += 1;
    }
  }

  cout << min(ans1, ans2) << endl;

  return 0;
}

