program main
    implicit none
    character(100) S
	integer N, i, j, k, l, ans, counter
	read(*, *) N
	read(*, *) S
	ans = 0
	do i = 1, N-1
	counter = 0
	    do j = 1, i
			do l = 1, j-1
				if (S(j: j) == S(l: l)) then
					goto 1
				end if
			end do
			do k = i+1, N
				if (S(j: j) == S(k: k)) then
					counter = counter + 1
					exit
				end if
			end do
1 continue
		end do
		ans = max(ans,counter)
	end do
	write(*, *) ans
end program main