import Control.Applicative ((<$>)) import Data.List (group, sort) main :: IO () main = solve <$> getLine >>= print solve :: String -> Int solve s = frac ln `div` d - 1 where ln = length s d = product . map (frac . length) . group . sort $ s frac :: Int -> Int frac n = f n 1 where f 0 p = p f x p = f (x-1) (x*p)