import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe
import qualified Data.Vector.Unboxed   as V

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, p] <- getIntList
  as <- V.fromList <$> getIntList

  let calcNBiscuits b i res | i == n         = res
                            | (b .&. 1) == 1 = calcNBiscuits (b `shiftR` 1) (i + 1) (res + as V.! i)
                            | otherwise      = calcNBiscuits (b `shiftR` 1) (i + 1) res

      solve :: Int -> Int -> Int
      solve b res | b == (1 `shiftL` n) = res
                  | otherwise =
                    let numb = calcNBiscuits b 0 0
                    in solve (b+1) (res + (if numb `mod` 2 == p then 1 else 0))

  print $ solve 0 0