def who_says_a_pun(n, s)
  i, j = 0, 0
  ans = 0
  while j < n
    s1 = s[i..j]
    s2 = s[(j + 1)..-1]
    if s2.include?(s1)
      ans = [ans, s1.size].max
      j += 1
    else
      i += 1
      j += 1
    end
  end
  ans
end

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