#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// modint: mod 計算を int を扱うように扱える構造体
template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
modint& operator++() {++val; return *this;}
modint& operator--() {--val; return *this;}
modint operator++(int) {val++; return *this;}
modint operator--(int) {val--; return *this;}
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator <=(const modint& r){return this->val<=r.val;}
    bool operator >(const modint& r){return this->val>r.val;}
    bool operator >=(const modint& r){return this->val>=r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}
//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}
// 行列累乗
template<class T> 
arr<T> modpowmat(arr<T> &a, ll n){
    int s = a.size();
    arr<T> b(s, vector<T>(s, 0));
    rep(i, s) b[i][i] = 1;

    while(n>0){
        if(n&1) {
            arr<T> c(s, vector<T>(s, 0));
            rep(i, s) rep(j, s) rep(k, s) c[i][j] += a[i][k] * b[k][j];
            b = c;
        }
        arr<T> c(s, vector<T>(s, 0));
        rep(i, s) rep(j, s) rep(k, s) c[i][j] += a[i][k] * a[k][j];
        a = c;
        n >>= 1;
    }
    return b;
}

ll com(ll n, ll k){
    if(k==0) return 1;
    vll a(k);
    rep(i, k) a[i] = n-i;

    vll p;
    FOR(i, 1, k+1){
        int d = i;
        while(d!=1 && d%2==0){
            p.push_back(2);
            d /= 2; 
        }

        for(int j=3; j*j<=d; j+=2){
            while(d!=1 && d%j==0){
                p.push_back(j);
                d /= j;
            }
        }

        if(d!=1) p.push_back(d);
    }

    rep(i, p.size()){
        rep(j, k){
            if(a[j]%(ll)p[i]==0){
                a[j] /= p[i];
                break;
            }
        }
    }

    rep(i, k-1) a[i+1] *= a[i];
    return a[k-1];
}

int main()
{
    int n, p; cin >> n >> p;
    vll a(n); 
    rep(i, n) cin >> a[i];
    ll even=0, odd=0;
    rep(i, n){
        if(a[i]%2) odd++;
        else even++;
    }

    even = (ll)powl(2, even);
    ll odd_even, odd_odd;

    if(p==0){
        ll t = 0;
        rep(i, odd+1){
            if(i%2==1) continue;
            t += com(odd, i);
        }
        pr(even*t);
    }else{
        ll t = 0;
        rep(i, odd+1){
            if(i%2==0) continue;
            t += com(odd, i);
        }
        pr(even*t);
    }
    return 0;}

Measured memory_bytes: 3716