main = interact $ show . solve

solve xs = go (length xs) 0 0 xs
where
  go n k i [_] = k
  go n k i (y:ys)
    | y == head ys = go n k (i + 1) ys
    | otherwise = go n k' (i + 1) ys
    where k' = maximum [k, i, n - i]