Kalindrome

Time limit: 0.2s Memory limit: 16MB Input: Output:

William loves strings and their properties, and he is especially fond of palindromes. He likes palindromes so much, that he started reading lots of research papers on them and finally stumbled upon a new kind of property that generalizes the palindrome concept: the kalindrome.

We say that a string is a kalindrome if, for some positive integer KK, it's possible to split the string in many substrings, each of them KK characters long, so that they can be read from left to right in the same way as right to left. More precisely: if we concatenate the substrings starting from the last one, we will recreate the original string.

For example: the word banaba is a kalindrome, because if we choose K=2K=2 then we obtain the substrings: ba, na, ba, which can indeed be concatenated starting from the last one, to reconstruct the original word.

You might have noticed that, by this definition, any string is a kalindrome! That's true, in fact we could choose KK to be equal to the string's length, and we would then obtain a single substring which would of course respect the definition! However, William is interested to know what's the smallest KK for a given string that would prove it is a kalindrome.

Help him by writing a program that automates this test!

Input data

The input contains the only integer NN, the length of the string to be tested. The second line contains a string SS, consisting of lowercase letters.

Output data

You will need to write a single line with an integer: the smallest positive integer KK that proves the kalindromeness of the string SS.

Constraints and Clarifications

  • 1N1061 \leq N \leq 10^6;
  • For tests worth 4040 points, KK is either 11 or NN.
  • For tests worth 4040 more points, 1N1 0001 \leq N \leq 1 \ 000.

Example 1

stdin

6
banaba

stdout

2

Explanation

In the first sample case, we can split the string in three 22-characters long substrings: ba, na, ba.

Example 2

stdin

12
eszyciyciesz

stdout

3

Explanation

In the second sample case, we can split the string in four 33-characters long substrings: esz, yci, yci, esz.

Log in or sign up to be able to send submissions!