import Control.Applicative
import Control.Monad
import Data.List

comb :: Int -> Int -> Int
comb n r = iterate (scanl1 (+)) [1, 1 ..] !! (n - r) !! r

main :: IO ()
main = do
    [n, p] <- fmap read . words <$> getLine :: IO [Int]
    as <- fmap read . words <$> getLine :: IO [Int]
    let bs = fmap (`mod` 2) as
    let x = length $ filter (== 0) bs
    let y = length $ filter (== 1) bs
    let ax = [comb x i | i <- [0 .. x]]
    let ay = if even p
             then [comb y i | i <- [0, 2 .. y]]
             else [comb y i | i <- [1, 3 .. y]]
    print (sum ax * sum ay)