import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import Data.Char
import Data.List
import Control.Monad

solve :: String -> Int
solve a = 1 + answer
  where
    vec = V.create $ do
      v <- VM.replicate 26 0
      forM a $ \c -> VM.modify v (+ 1) (ord c - ord 'a')
      return v
    lst = V.toList vec
    answer = sum $ zipWith (*) lst $ map sum $ tail (tails lst)

main :: IO ()
main = do
  cont <- getContents
  let [a] = words cont
      answer = solve a
  putStrLn $ show answer
  
