#K62187. Palindrome Index

    ID: 31476 Type: Default 1000ms 256MiB

Palindrome Index

Palindrome Index

Given a string s, determine the index of the character that can be removed to turn s into a palindrome. A palindrome is a string that reads the same forwards and backwards. If the string is already a palindrome or if no single removal results in a palindrome, print -1.

The challenge is to correctly identify the character removal such that the remaining elements form a palindrome. If there exist multiple possibilities, output the first valid index encountered when scanning from the beginning.

Note: Input is read from standard input (stdin) and the result should be written to standard output (stdout).

inputFormat

The input consists of a single line containing the string s.

outputFormat

Output a single integer: the index of the character that can be removed to form a palindrome. If the string is already a palindrome or if no valid removal exists, output -1.

## sample
aaab
3