The Canyon Echo
A canyon has a peculiar property: when you shout a word, it echoes back the first part of your word reversed. For instance, if you shout "abaca", the canyon echoes back "acaba" (the reverse of "abaca").
However, there's a magical point where the echo is perfectly symmetric: when the initial segment of your word is palindromic (reads the same forwards and backwards), the echo pattern becomes symmetric and beautiful.
Given a word, find the length of the longest initial segment (prefix) that forms a palindrome.
Input
The first line contains n (1 ≤ n ≤ 10^5), the length of the word.
The second line contains a string s of length n consisting of lowercase letters.
Output
Print the length of the longest prefix of s that is a palindrome.
Notes
A palindrome reads the same forwards and backwards. Every single character is a palindrome by itself.
In the first example, the word is "abaca". The palindromic prefixes are "a" (length 1) and "aba" (length 3), so the answer is 3.