import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Array

readInt = fst . fromJust . BS.readInt

readString = map BS.unpack . BS.words

getInt = readInt <$> BS.getLine

getString = readString <$> BS.getLine

comb :: Int -> [a] -> [[a]]
comb _ [] = []
comb 1 xs = [[x] | x <- xs]
comb n (x : xs) =
  [x : y | y <- comb (n -1) xs]
    ++ comb n xs

pickString :: Array Int Char -> [Int] -> String
pickString s [] = []
pickString s (x : xs) = (s ! x) : pickString s xs

pickStrings :: Array Int Char -> [[Int]] -> [String] -> [String]
pickStrings s [] ys = ys
pickStrings s (xs : xss) ys
  | y' `elem` ys = pickStrings s xss ys
  | otherwise = pickStrings s xss (y' : ys)
  where
    y' = pickString s xs

main = do
  n <- getInt
  [s] <- getString
  let xss = comb 3 [1 .. n]
  let s' = listArray (1, length s) s
  print $ length (pickStrings s' xss [])
