main = do
  [n, p] <- readNums
  as <- rradNums
  print $ f p (g as)

g as = (x, y)
  where x = length . filter even $ as
              y = length . filter odd $ as

f p (x, y) = frac x * sum [ c y k | k <- [0 .. y], even (k - p)]

c n k = frac n `div` (frac k * frac (n - k))

frac 0 = 1
frac n = n * frac (n - 1)

