import Control.Applicative import Control.Monad import qualified Data.ByteString.Char8 as B import Data.Maybe (fromJust) import Text.Printf import Data.List import Debug.Trace -- or readInteger readInts :: B.ByteString -> [Int] readInts = map (fst . fromJust . B.readInt) . B.words getInts :: IO [Int] getInts = liftM readInts B.getLine f n [] = 1 f n (x:xs) = c n x * f (n-x) xs where c n m = product [1..n] `div` product [1..m] `div` product [1..(n-m)] g = map toInteger . map length . group . sort main = do s <- getLine print $ (`mod` 573) $ (f (toInteger $ length s) $ g s) - 1