let () =
  let n, p = Scanf.scanf "%d %d\n" (fun n p -> n, p) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Array.fold_left (fun (odd, even) a ->
    if a mod 2 = 0 then (2 * odd, 2 * even)
    else (odd + even, odd + even)) (0, 1) as_
  |> (if p = 1 then fst else snd)
  |> Printf.printf "%d\n"