{-# LANGUAGE BangPatterns #-}

import Control.Applicative ((<$>))
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as BS
import Data.List (scanl', tails)

main :: IO ()
main = do
  n <- read <$> getLine
  s <- getLine
  print $ maximum
    $ zipWith (\ !gap !dropped -> min gap $ test s $ dropped)
       [1..n-1]
    $ tail $ tails s

test :: String -> String -> Int
test v1 v2
 = maximum
   $ scanl' (\ !l !b -> if b then l+1 else 0) (0::Int)
   $ zipWith (==) v1 v2
