n = gets.to_i
s = gets.chomp
size = s.size
div, mod = s.size.divmod(2)
ans = 0
if div >= 50
  deduction = div - 50
  div -= deduction
  mod += deduction * 2
end
until ans != 0
  0.upto(mod).each do |f_start|
    (f_start + div).upto(size - div).each do |l_start|
      if s[f_start, div] == s[l_start, div]
        ans = div
      end
    end
  end
  if ans != 0
    break
  else
    div -= 1
    mod += 2
  end
end

if ans == 50
  div, mod = s.size.divmod(2)
  ans = 0
  until ans != 0
    0.upto(mod).each do |f_start|
      (f_start + div).upto(size - div).each do |l_start|
        if s[f_start, div] == s[l_start, div]
          ans = div
        end
      end
    end
    if ans != 0
      break
    else
      div -= 1
      mod += 2
    end
  end
end

puts ans == -1 ? 0 : ans
