P23635 [AtCoder] Concatenated Palindrome
普及+
题目描述

Problem Description

Given a string $ S $ consisting of lowercase English letters.
We want to make $ S $ a palindrome by concatenating any string $ T $ (including an empty string) consisting of lowercase English letters to the end of $ S $.
Find the minimum length of the string $ T $ that satisfies this condition.

Input Format

The input is given from the standard input in the following format:

$ S $

Output Format

Determine the minimum length of the string $ T $ that satisfies the condition.

Sample Input and Output

Sample Input #1

abcde

Sample Output #1

4

Sample Input #2

level

Sample Output #2

0

Sample Input #3

codethanksfestival

Sample Output #3

17

Sample Input #4

abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcb

Sample Output #4

1

Notes/Hints

Constraints

  • $1 \leq |S| \leq 50$ ($ |S| $ is the length of the string $ S $)
  • The string $ S $ consists of lowercase English letters.

Sample Explanation 1

If $ T = "dcba" $, the concatenated string of $ S $ and $ T $ becomes a palindrome. This string $ T $ has the minimum length among those that satisfy the condition, so the answer is $ 4 $.

Sample Explanation 2

Since the string $ S $ is already a palindrome, the string $ T $ can be an empty string, which satisfies the condition. The length of an empty string is $ 0 $, so the answer is $ 0 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
abcde
样例输出
4