import Data.List (nub) takeChar :: (String, String) -> [(String, String)] takeChar ([], snew) = [([], snew)] takeChar (sres, snew) = [(sresh, snewh), (sresl, snewl)] where (sresh, snewh) = (tail sres, snew ++ [head sres]) (sresl, snewl) = (init sres, snew ++ [last sres]) mapTakeChar :: [(String, String)] -> [(String, String)] mapTakeChar ps = concat $ map takeChar ps countPossibleStrings :: String -> Int countPossibleStrings s = length $ nub $ map snd $ foldr (const mapTakeChar) [(s, [])] [1 .. length s] main :: IO () main = print . countPossibleStrings =<< getLine