import Data.List (group, sort) factorial :: Integral a => a -> a factorial 0 = 1 factorial 1 = 1 factorial n = n * factorial (n - 1) getPermutations :: String -> Integer getPermutations s = flip mod 573 $ subtract 1 $ factorial l `div` (product . map factorial) ns where l = fromIntegral $ length s ns = map fromIntegral $ map length $ group $ sort s main :: IO () main = print . getPermutations =<< getLine