import Control.Applicative import Data.List fact 1 = 1 fact n = n * fact (n-1) main = do s <- getLine print $ (`mod`573) $ (fact.fromIntegral.length $ s) `div` (product . map (fact.fromIntegral.length) . group . sort $ s) - 1