#include <stdio.h>
#include <math.h>
#include <string.h>

main()
{
	int N = 2*pow(10,5);
	char T[N];
	scanf("%s", &T);
	int length = strlen(T);
	
	if (length <= 2*pow(10,5))
	{
		int count[256] = {0}, i, j, temp, odd = 0, shuffle = 0;
		char odd_character;
		
		for (i = 0; i < length; i++) count[(int)(T[i])]++;
		
		for (i = 0; i < 256; i++)
		{
			if (count[i] != 0)
			{
				if (count[i] % 2 != 0)
				{
					if (odd < 1)
					{
						odd_character = i;
						odd++;
					}
					
					else return 0;
				}
			}
		}
		
		for (i = 0, j = length-1; i < length, j > 0; i++, j--)
		{
			if (T[i] != T[j])
			{
				if (T[i+1] == T[i])
				{
					temp = T[j];
					T[j] = T[i+1];
					T[i+1] = temp;
					shuffle += j-(i+1);
				}
			}
		}
		
		for (i = 0; i < length; i++)
		{
			if (T[i] == odd_character)
			{
				temp = T[(length-1)/2];
				T[(length-1)/2] = T[i];
				T[i] = temp;
				if (((length-1)/2) > i) shuffle += ((length-1)/2)-i;
				if (((length-1)/2) < i) shuffle += i-((length-1)/2);
			}
		}
		
		if (shuffle == 0) shuffle = 1;
		printf("%d", shuffle);
	}
}