An abelian square is a string of even length where the first half of the string is an anagram of the second half of the string. Here are some examples:
hannah
is an abelian square.reappear
is an abelian square.racecar
is NOT an abelian square as it has odd length.soot
is NOT an abelian square, but the substringoo
is an abelian square.
Given a string, determine the length of the longest substring that is an abelian square.
Input Specification
The first line of input contains an integer . The next line contains a lower-case string of characters.
Output Specification
The length of the longest substring that is an abelian square.
Sample Input 1
8
reappear
Sample Output 1
8
Sample Input 2
11
programming
Sample Output 2
2
Comments