#6543. 智能工厂的回文质检

智能工厂的回文质检

Title Description

On the quality inspection assembly line of the future factory, the robotic arm is arranging the product sequence. Each product has a letter identifier, and quality inspection requires that the final sequence must be a palindrome. The robotic arm can only exchange the positions of two adjacent products at a time. Please calculate the minimum number of operations required to complete the quality inspection.

Special conditions

When there is a situation where a palindrome cannot be formed (such as multiple letters appearing odd times), the system will automatically sound an alarm

Input format

A string composed of lowercase letters (length 1000\le 1000)

Output format

Minimum number of operations or 1-1

Example

aabb
2