P24938 [AtCoder] [ARC019B] A Particular Name
普及+
题目描述

Problem Description

The game is approaching its middle stage, and I just got a ship to sail out to the sea. I want to challenge a new dungeon soon, but first, I need to give the ship a cool name.

I thought about just keeping the default name to move forward quickly, but that would be too boring. So, I decided to change just one character from the default name.

By the way, in such situations, characters in programming contest problems often have inexplicable obsessions, like "let's make the name a palindrome." Unlike those ordinary characters, I don't have such strange obsessions. I want the ship's name to not be a palindrome.

So, how many non-palindromic names can I create by changing just one character from the default name? Let's write a program to find out. By the way, the only characters allowed for the ship's name are uppercase alphabets.

Oh, you think wanting a non-palindromic name is also a strange obsession? Well, you're right, maybe I can't escape my destiny as a character in a programming contest. But if my strange obsessions make many people enjoy programming contests, that's a good thing, isn't it?

Input Format

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

$ A $

  • The first line contains the default name of the ship, $ A $.
  • $ A $ is a string consisting of uppercase alphabets with a length between 1 and $3 \times 10^5$ characters.

Output Format

Output a single line with the number of non-palindromic strings that can be obtained by changing exactly one character from the default name to another uppercase alphabet.

A palindrome is a string that reads the same forward and backward. For example, ANNA, MADAM, X are palindromes, but AB, ARC are not.

Include a newline at the end of the output.

Sample Input and Output

Sample Input #1

ARC

Sample Output #1

73

Sample Input #2

S

Sample Output #2

0

Sample Input #3

NOLEMONNOMELON

Sample Output #3

350

Notes/Hints

Sample Explanation 1

  • Changing the first character A to another character:
  • Changing it to C results in CRC, which is a palindrome.
  • Changing it to any of the other 24 characters (e.g., BRC, XRC, etc.) results in non-palindromic names.
  • Changing the second character R to another character:
  • Any change results in non-palindromic names, so there are 25 possibilities.
  • Changing the third character C to another character:
  • Changing it to A results in ARA, which is a palindrome.
  • Changing it to any of the other 24 characters results in non-palindromic names.

Therefore, the answer is $ 24 + 25 + 24 = 73 $. Note that we do not count the name ARC itself, which has not been changed.

Sample Explanation 2

A single-character string is always a palindrome.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
ARC
样例输出
73