//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
bool arr[55]={false}; 
vector<ll> produce_prim_number() 
{ 
        vector<ll> prim; 
        prim.push_back(2); 
        ll i,j; 
        for(i=3;i*i<=55;i+=2) 
        { 
                if(!arr[i]) 
                { 
                        prim.push_back(i); 
                        for(j=i*i;j<=55;j+=i) 
                                arr[j]=true; 
                } 
        } 
        while(i<55) 
        { 
                if(!arr[i]) 
                        prim.push_back(i); 
                i+=2; 
        } 
        return prim; 
} 
//计算n!中素数因子p的指数  
ll cal(ll x,ll p) 
{ 
        ll ans=0; 
        long long rec=p; 
        while(x>=rec) 
        { 
                ans+=x/rec; 
                rec*=p; 
        } 
        return ans; 
} 
//计算n的k次方对m取模，二分法  
ll pow(long long n,ll k) 
{ 
        long long ans=1; 
        while(k) 
        { 
                if(k&1) 
                { 
                        ans=(ans*n); 
                } 
                n=(n*n); 
                k>>=1; 
        } 
        return ans; 
} 
//计算C（n，m）  
ll comb(ll n,ll m) 
{ 
        vector<ll> prim=produce_prim_number(); 
        long long ans=1; 
        ll num; 
        for(ll i=0;i<prim.size()&&prim[i]<=n;++i) 
        { 
                num=cal(n,prim[i])-cal(m,prim[i])-cal(n-m,prim[i]); 
                ans=(ans*pow(prim[i],num)); 
        } 
        return ans; 
}  
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	ll n,p,cnt1=0,cnt2=0,a[55];
	ll ans;	
	cin>>n>>p;
	for(ll i=1;i<=n;i++)
	cin>>a[i];
	if(p==0){
		ll sol=0;
		ans=1;
		for(ll i=1;i<=n;i++)
		if(a[i]%2==0)
		cnt1++;
		else
		cnt2++;
		if(cnt1>=1)
		for(ll j=1;j<=cnt1;j++){
			ans+=comb(cnt1,j);
		}
		if(cnt2>=2)
		for(ll j=2;j<=cnt2;j+=2){
			sol+=comb(cnt2,j);
		}
		cout<<ans*(sol+1);
	}
	else{
		ll sol=0;
		ans=0;
		for(ll i=1;i<=n;i++)
		if(a[i]%2==0)
		cnt1++;
		else
		cnt2++;
		if(cnt1>=1)
		for(ll j=1;j<=cnt1;j++){
			sol+=comb(cnt1,j);
		}
		if(cnt2>=1)
		for(ll j=1;j<=cnt2;j+=2){
			ans+=comb(cnt2,j);
		}
		cout<<ans*(sol+1);
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256