import Control.Applicative ((<$>))

cartesianPower :: [Int] -> Int -> [[Int]]
cartesianPower xs 0 = []
cartesianPower xs 1 = [ [i] | i <- xs ]
cartesianPower xs n = [ i : x | i <- xs, x <- cartesianPower xs (n - 1) ]

solve iss a xs = filter (\is -> sum (map (xs !!) (snd $ unzip $ filter (\a -> fst a == 1) $ zip is [0 ..])) == (a * length (snd $ unzip $ filter (\a -> fst a == 1) $ zip is [0 ..]))) iss

main = do
  [n, a] <- fmap read <$> words <$> getLine :: IO [Int]
  xs <- fmap read <$> words <$> getLine :: IO [Int]
  putStrLn (show $ pred $ length $ solve (cartesianPower [0, 1] n) a xs)
