import Data.List fact n = product [1..n] main = getLine >>= print . nswap nswap :: String -> Integer nswap s = (div (fact (fromIntegral (length s))) (product (map fact ldup)) - 1) `mod` 573 where ldup = map (fromIntegral . length) (group (sort s))