main :: IO ()
main = do
  [_, p] <- map read.words <$> getLine :: IO [Integer]
  as <- map read.words <$> getLine :: IO [Integer]
  let odds = length $ filter odd as
      evens = length $ filter even as
      comb _ 0=1
      comb n r=div((n-r+1)*comb n(r-1))r
  print $ case p of
    0 -> sum [comb odds x| x<-[0,2..odds]] * sum [comb evens x| x<-[0..evens]]
    _ -> sum [comb odds x| x<-[1,3..odds]] * sum [comb evens x| x<-[0..evens]]
