import qualified Data.Map as M

main = do
  a <- getLine
  print $ solve M.empty (length a) a
 
solve _ _ [_] = 1
solve d n (x:xs)  = solve d' n' xs + n' - M.findWithDefault 0 x d
  where 
    d' = M.insertWith (+) x 1 d
    n' = pred n