import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl (wrds toIex) <*> getl (wrds toIex) >>= print

solve :: [Integer] -> [Integer] -> Integer
solve [n,a] = genericLength . filter (av a) . comb

av :: Integer -> [Integer] -> Bool
av x ys
  | null ys = False
  | otherwise = genericLength ys * x == sum ys

comb :: [Integer] -> [[Integer]]
comb = filterM (\_ -> [False,True])

toIex :: String -> Integer
toIex = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine
