N = int(input())
S = list(input())
dp = [[0]*N for _ in range(N)]
dp[N-1][N-1] = 1
for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[N-1][i] = 1

for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[i][N-1] = 1

for i in range(N-1, 0, -1):
  for j in range(N-1, 0, -1):
    if S[i-1] == S[j-1]:
      dp[i-1][j-1] = dp[i][j] + 1

ans = 0
for i in range(N):
  for j in range(i+1, N):
    ans = max(ans, min(dp[i][j], j-i))
print(ans) N = int(input()) N int(input()) int input() input S = list(input()) S list(input()) list input() input [0]*N for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [0]*N [0] 0 N dp = [[0]*N for _ in range(N)] dp [[0]*N for _ in range(N)] dp[N-1][N-1] = 1 dp[N-1][N-1] [N-1] dp N-1 N 1 N-1 N 1 1 for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[N-1][i] = 1 i range(N-1, -1, -1) range N-1 N 1 -1 -1 if S[i] == S[-1]:
    dp[N-1][i] = 1 S[i] == S[-1] S[i] S i S[-1] S -1 dp[N-1][i] = 1 dp[N-1][i] [N-1] dp N-1 N 1 i 1 for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[i][N-1] = 1 i range(N-1, -1, -1) range N-1 N 1 -1 -1 if S[i] == S[-1]:
    dp[i][N-1] = 1 S[i] == S[-1] S[i] S i S[-1] S -1 dp[i][N-1] = 1 dp[i][N-1] [i] dp i N-1 N 1 1 for i in range(N-1, 0, -1):
  for j in range(N-1, 0, -1):
    if S[i-1] == S[j-1]:
      dp[i-1][j-1] = dp[i][j] + 1 i range(N-1, 0, -1) range N-1 N 1 0 -1 for j in range(N-1, 0, -1):
    if S[i-1] == S[j-1]:
      dp[i-1][j-1] = dp[i][j] + 1 j range(N-1, 0, -1) range N-1 N 1 0 -1 if S[i-1] == S[j-1]:
      dp[i-1][j-1] = dp[i][j] + 1 S[i-1] == S[j-1] S[i-1] S i-1 i 1 S[j-1] S j-1 j 1 dp[i-1][j-1] = dp[i][j] + 1 dp[i-1][j-1] [i-1] dp i-1 i 1 j-1 j 1 dp[i][j] + 1 dp[i][j] [i] dp i j 1 ans = 0 ans 0 for i in range(N):
  for j in range(i+1, N):
    ans = max(ans, min(dp[i][j], j-i)) i range(N) range N for j in range(i+1, N):
    ans = max(ans, min(dp[i][j], j-i)) j range(i+1, N) range i+1 i 1 N ans = max(ans, min(dp[i][j], j-i)) ans max(ans, min(dp[i][j], j-i)) max ans min(dp[i][j], j-i) min dp[i][j] [i] dp i j j-i j i print(ans) print ans N = int(input()) int(input()) N dp = [[0]*N for _ in range(N)] [[0]*N for _ in range(N)] dp ans = 0 0 ans ans = max(ans, min(dp[i][j], j-i)) max(ans, min(dp[i][j], j-i)) ans S = list(input()) list(input()) S
N = int(input())
S = list(input())
dp = [[0]*N for _ in range(N)]
dp[N-1][N-1] = 1
for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[N-1][i] = 1

for i in range(N-1, -1, -1):
  if S[i] == S[-1]:
    dp[i][N-1] = 1

for i in range(N-1, 0, -1):
  for j in range(N-1, 0, -1):
    if S[i-1] == S[j-1]:
      dp[i-1][j-1] = dp[i][j] + 1

ans = 0
for i in range(N):
  for j in range(i+1, N):
    ans = max(ans, min(dp[i][j], j-i))
print(ans)