Example

Input

6 3
1 0 0 1 0 1
1 3 2


Output

1
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N, M;
    cin >> N >> M;

    vector<int> b(N);
    for (int i = 0; i < N; i++) cin >> b[i];

    int WHITE = 0, BLACK = 0;
    for (int i = 0; i < N; i++) {
        if (b[i] == 0) WHITE++;
        if (b[i] == 1) BLACK++;
    }

    vector<int> p(M);
    for (int i = 0; i < M; i++) cin >> p[i];

    vector<vector<int>> a(2, vector<int>());
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < M; j++) {
            for (int k = 0; k < p[j]; k++) {
                a[i].push_back((j + i) % 2);
            }
        }
    }

    int ans = INT_MAX;
    for (int obeee = 0; obeee < 2; obeee++) {
        auto d = a[obeee];
        int w_count = 0, b_count = 0;
        for (int j = 0; j < d.size(); j++) {
            if (d[j] == 0) w_count++;
            if (d[j] == 1) b_count++;
        }
        if (w_count != WHITE || b_count != BLACK) continue;

        int sum = 0;
        for (int i = 0; i < N; i++) {
            if (b[i] != d[i]) {
                int index;
                for (int j = N - 1; j > i; j--) if (d[j] == b[i]) index = j;
                for (int j = index; j > i; j--) sum++, swap(d[j - 1], d[j]);
            }
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}




























































