import Data.List
cmb n k = foldl' (\a i->div (a*(n-i+1)) i) 1 [1..k]
main=do
    [n,p]<-map read.words<$>getLine::IO[Int]
    as<-map read.words<$>getLine::IO[Int]
    let en = length $ filter even as
    let os = n-en
    print $ if p==0 then f1 en os else f2 en os
--
f1 en os = 2^en * (1 + sum (map (cmb os) [2,4..os]))
f2 en os = 2^en * sum (map (cmb os) [1,3..os])
