#include <bits/stdc++.h>
#define MAXN 1000000

using namespace std;

int v[MAXN + 1];


int main()
{
    int n, k, i, cnt1;

    cin >> n >> k;
    cnt1 = 0;
    for(i = 0; i < n; i++){
        cin >> v[i];
        if(v[i] == 1){
            cnt1++;
        }
    }
    if(k % 2 == cnt1 % 2){
        cout << "1\n";
    }else{
        cout << "0\n";
    }
    return 0;
}
