import Data.List (inits, tails, intersect, nub)

cuts :: [a] -> [([a], [a])]
cuts xs = zip (tail $ inits $ init xs) (init $ tails $ tail xs)

solve :: String -> Int
solve = maximum . map (length . nub . uncurry intersect) . cuts

main :: IO ()
main = do
  _n <- read <$> getLine :: IO Int
  s <- getLine
  print $ solve s
