PivotOJ

Palindrome Type

시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC Asia Seoul Regional 2022BOJ 26110

문제

A palindrome string is a word which reads the same backward as forward, such as madam or racecar. In this problem we only consider strings with lowercase alphabets.

We newly define the types of palindromes. If a string is not a palindrome, we try to make it a palindrome by removing the minimum number of characters in the string. For a string ww, if kk is the minimum number of characters removed to make the string a palindrome, we call the string ww type-kk palindrome. Thus, if ww is a palindrome, then ww is a type-00 palindrome.

Given a string ww, write a program to determine if ww is a type-kk palindrome where k=0,1,2,3k = 0, 1, 2, 3.

입력

Your program is to read from standard input. The input is a single line containing a string ww with length nn (5 ≤ n ≤ 10^5) of lowercase alphabets.

출력

Your program is to write to standard output. Print exactly one line. The line should contain a number kk among {0,1,2,3,1}\{0, 1, 2, 3, -1\} if the input string is a type-kk palindrome where k=0,1,2,3k = 0, 1, 2, 3 and otherwise 1-1. The negative number 1-1 means the input string is not a type-kk palindrome where k=0,1,2,3k = 0, 1, 2, 3.

예제

예제 1

입력
aababaa
출력
0

예제 2

입력
abccbbab
출력
2

예제 3

입력
acmicpc
출력
-1
코드를 제출하려면 로그인하세요.