AlgoUniversity
  • Go Back
Discussion
Extended Palindrome :

Author

Yash Sahijwani

Difficulty Level : Easy

Submissions : 597

Asked In : Microsoft

Marks :50

: 4 | : 0

A string is called a palindrome string if the reverse of the string is same as the original string.

A string $$$S$$$ is called an extended palindrome string if the string becomes a palindrome after chucking it in chunks of length $$$d$$$, where $$$d$$$ is either 1 or a prime divisor of $$$|S|$$$, where $$$|S|$$$ is the length of the string. For example, 'abcxyzabc' is not a palindrome but an extended palindrome as it can be broken as {abc}{xyz}{abc} into chunks of length 3.

The degree of a string is defined as the minimum possible chunk length that can make the string an extended palindrome.

Given a string $$$S$$$, find its degree.

Input

The first line of input consists of a string $$$S$$$ $$$-$$$ $$$(1 \leq |S| \leq 10^5)$$$.

Output

Output a single integer - the degree of the string $$$S$$$. In case there is no possible chunk length that can make the string an extended palindrome, output -1.

Examples

Input
abba
Output
1
Input
abcxyzabc
Output
3

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.