def who_says_a_pun(n, s)
  (n / 2).downto(1) do |l|
    0.upto(n - l * 2) do |i|
      (i + l).upto(n - l) do |j|
        return l if s[i...(i + l)] == s[j...(j + l)]
      end
    end
  end
  0
end

n = gets.to_i
s = gets.chomp
puts who_says_a_pun(n, s)