import Control.Applicative( (<$>))
import Data.Array.IArray( listArray, Array, (!))

main = do
    let
	readLine = map read . words <$> getLine
    [n_, p_] <- readLine
    as_ <- readLine
    let
	facts _ 0 = 1:(facts 1 1)
	facts 1 1 = 1:(facts 1 2)
	facts n i = let
		    a = n*toInteger i
		in
		    a:(facts a $ i+1)

	factArr::Array Int Integer
	factArr = listArray (0,n_) (facts undefined 0)

	fact 0 = 1
	fact 1 = 1
	fact n = factArr!n

	combi::Int->Int->Integer
	combi n r = (fact n) `quot` (fact r) `quot` (fact $ n-r)

	numEven = length $ filter even as_
	numOdd = n_ - numEven

	a = sum [ combi numEven  r | r<-[0..numEven]]
	p0 = let
		b = sum [ combi numOdd  r | r<-[0,2..numOdd]]
	    in
		a*b

	p1 = let
		b = sum [ combi numOdd  r | r<-[1,3..numOdd]]
	    in
		a*b
	
    print $ if p_==0
	    then p0
	    else p1