import Control.Applicative
import Control.Monad
import Data.Array.IO


main = do
  [n,p] <- map read . words <$> getLine :: IO [Int]
  as <- map ((`mod` 2) . read) . words <$> getLine :: IO [Int]

  dp <- newArray ((0,0),(n,2)) 0 :: IO (IOArray (Int,Int) Integer)

  writeArray dp (0,0) 1
  forM_ (zip [1..n] as) $ \(i,a) -> do
    if even a then do
      writeArray dp (i,0) =<< (*2) <$> readArray dp (i-1,0)
      writeArray dp (i,1) =<< (*2) <$> readArray dp (i-1,1)
      else do
      writeArray dp (i,0) =<< (+) <$> readArray dp (i-1,0) <*> readArray dp (i-1,1)
      writeArray dp (i,1) =<< (+) <$> readArray dp (i-1,0) <*> readArray dp (i-1,1)

  print =<< readArray dp (n,p)
