-- import Data.Array
import Data.List

main = do
  li <- getLine
  let n = read li
  s <- getLine
  let ans = compute n s
  print ans

{- naive -}

compute :: Int -> String -> Int
compute n s = length
  [ ()
  | a:s1 <- tails s
  , (b:s2,d) <- zip (tails s1) [1..]
  , a /= b
  , (c,e) <- zip s2 [1..]
  , a /= c, b /= c, d /= e
  ]
