#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int b[2], p[20];
int bb[20]; //もとの数列
int const MOD = 1e9 + 7;
int main(void)
{
    int N, M;
    cin >> N >> M;

    vector<int> ori1, s1, t1;
    string ori = "";
    for (int i = 0; i < N; ++i)
    {
        char s;
        cin >> s;
        ori += s;
        b[s - '0']++;
        if (s == '1')
        {
            ori1.push_back(i);
        }
    }
    if (N == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    int even = 0, odd = 0;
    for (int i = 0; i < M; ++i)
    {
        cin >> p[i];
        if (i % 2 == 0)
            even += p[i];
        else
            odd += p[i];
    }

    //b[0]は0の個数, b[1]は1の個数
    //0が偶数番目に並ぶとき
    string s = "", t = "";

    if (b[0] == b[1])
    {
        for (int i = 0; i < M; ++i)
        {
            if (i % 2 == 0)
            {
                for (int j = 0; j < p[i]; ++j)
                {
                    s += '0';
                }
            }
            else
            {
                for (int j = 0; j < p[i]; ++j)
                {
                    s += '1';
                }
            }
        }

        for (int i = 0; i < M; ++i)
        {
            if (i % 2 == 0)
            {
                for (int j = 0; j < p[i]; ++j)
                {
                    t += '1';
                }
            }
            else
            {
                for (int j = 0; j < p[i]; ++j)
                {
                    t += '0';
                }
            }
        }
        for (int i = 0; i < N; ++i)
        {
            if (s[i] == '1')
            {
                s1.push_back(i);
            }
            else
            {
                t1.push_back(i);
            }
        }
        int ans = 0, ans1 = 0;
        for (int i = 0; i < ori1.size(); ++i)
        {
            ans += abs(ori1[i] - s1[i]);
            ans1 += abs(ori1[i] - t1[i]);
        }
        cout << min(ans, ans1) << endl;
        return 0;
    }
    else if (b[0] == even)
    {
        for (int i = 0; i < M; ++i)
        {
            if (i % 2 == 0)
            {
                for (int j = 0; j < p[i]; ++j)
                {
                    s += '0';
                }
            }
            else
            {
                for (int j = 0; j < p[i]; ++j)
                {
                    s += '1';
                }
            }
        }
        for (int i = 0; i < N; ++i)
        {
            if (s[i] == '1')
            {
                s1.push_back(i);
            }
        }
        int ans = 0;
        for (int i = 0; i < ori1.size(); ++i)
        {
            ans += abs(ori1[i] - s1[i]);
        }
        cout << ans << endl;
        return 0;
    }
    else
    {
        for (int i = 0; i < M; ++i)
        {
            if (i % 2 == 0)
            {
                for (int j = 0; j < p[i]; ++j)
                {
                    s += '1';
                }
            }
            else
            {
                for (int j = 0; j < p[i]; ++j)
                {
                    s += '0';
                }
            }
        }
        for (int i = 0; i < N; ++i)
        {
            if (s[i] == '1')
            {
                s1.push_back(i);
            }
        }
        int ans = 0;
        for (int i = 0; i < ori1.size(); ++i)
        {
            ans += abs(ori1[i] - s1[i]);
        }
        cout << ans << endl;
        return 0;
    }
}


Measured memory_bytes: 3224