let id x = x
let (n,p) = Scanf.scanf "%d %d\n" (fun a b -> (a,b))
let n' = let rec func' cnt =
           if cnt = n then 1
             else 2 * func' (cnt+1) in func' 0

let array = Array.init n (fun _ -> (Scanf.scanf "%d ") id)
let list = Array.to_list array

let ar = Array.init n (fun _ -> 0)

let rec sum cnt k =
  if cnt = n then k
    else sum (cnt + 1) (k + array.(cnt) * ar.(cnt))

let rec array_plus n =
  if ar.(n) = 0 then ar.(n) <- 1
  else
    (ar.(n) <- 0 ; array_plus (n + 1)) 

let rec func cnt k =
  if (cnt+1) = n' then
    let y' = if (sum 0 0) mod 2 = p then 1 else 0 in
    k + y'
  else
    let y = if (sum 0 0) mod 2 = p then 1 else 0 in
    (array_plus 0;
    func (cnt+1) (k+y))

let ans = func 0 0
 
let () =
  Printf.printf "%d\n" ans