import Data.List

main = do
  _ <- getLine
  x <- getLine
--  print $ ts x
--  print . map pf $ ts x
  print . sum . map pfn $ ts x

ts :: String -> [String]
ts = init . tails

-- pf [x]    = (x,[])
-- pf (x:xs) = (x,filter p .subsequences $ filter (/= x) xs)


pfn :: String -> Int
pfn [x]    = 1
pfn (x:xs) = length . filter p . subsequences $ filter (/= x) xs

p :: String -> Bool
p [] = True
p [x] = True
p (x:xs)
  | x `elem` xs = False
  | otherwise = p xs