module Main where
 
import           Data.List
 
mapTuple :: (a -> b) -> (a, a) -> (b, b)
mapTuple f (a1, a2) = (f a1, f a2)
 
cut :: String -> Int
cut input = maximum $ map length leng
  where
    leng  = map (uncurry intersect . mapTuple nub) part
    part = map (`splitAt` input) [1..len]
    len  = length input
 
main :: IO()
main = interact $ show . cut . last . words
