main = do
 [n,p] <- map read . words <$> getLine :: IO [Integer]
 as <- map read . words <$> getLine :: IO [Integer]
 print (biscuits n p as)

biscuits n p as
 | p == 0 = (2^evens) * sum (map (comb odds) [0,2..odds])
 | otherwise = (2^n) - ((2^evens) * sum (map (comb odds) [0,2..odds]))
 where
  odds = fromIntegral $ length (filter odd as)
  evens = n - odds 

fact n = product [1..n]

comb n r = div (fact n) (fact r * fact (n-r))