import qualified Data.Map.Lazy as M

main = do
  a <- getLine
  print $ solve M.empty a
 
solve _ [] = 1
solve d (x:xs)  = solve (M.mapWithKey f d) xs + M.foldr (+) 0 (M.delete x d)
  where 
    f c n = if c == x then succ n else n
    