import Control.Applicative
import Data.List

main = do
    n <- readLn
    s <- getLine
    print $ solve n s

solve :: Int -> String -> Int
solve n s = maximum nums
    where nums = map (g s) [1..(n-1)]

g s n = f l r
    where (left,right) = splitAt n s
          l = nub left
          r = nub right

f xs ys = common xs ys 0
common :: String -> String -> Int -> Int
common [] _ n = n
common _ [] n = n
common (x:xs) ys n = if elem x ys then common xs ys (n+1) else common xs ys n