import Control.Arrow
import Data.Char
import Data.List

main :: IO ()
main = do
  _ <- getInt
  s <- getString
  print . maximum . map (length . uncurry intersect) . map (unique *** unique) $ zip (inits s) (tails s)

getInt :: IO Int
getInt = read <$> getLine

getString :: IO String
getString = getLine

unique :: Ord a => [a] -> [a]
unique = map head . group . sort
