n = gets.to_i
s = gets.chomp
len = n / 2
flag = false

while len > 0 do
  for i in 0..(n - len * 2) do
    part = s.slice(i, len)
    step = 1
    if len >= 2
      step = part.index(part[0], 1)
      step = len if step.nil?
    end
    (i + len).step(n - len + 1, step) do |j|
      comp = s.slice(j, len)
      if part == comp
        flag = true
        break
      end
    end
    break if flag
  end
  break if flag
  len -= 1
end
puts len
