import Data.List (tails)

main :: IO ()
main = do
  _ <- getLine
  s <- getLine
  print $ ans s

ans :: String -> Int
ans str = subseq str' where
  str' = ' ' : str
  subseq [s] = 1
  subseq (s:sx) = let sx' = filter (/= s) sx
                  in sum $ zipWith (\t ts -> if ts == []
                                             then 1
                                             else subseq (t:ts) + 1) sx' (tail $ tails sx')