#include <bits/stdc++.h>
#define LL long long
using namespace std;

int main()
{
    string s;
    cin >> s;
    LL min, max;
    max = 0;
    min = 0;

    unordered_map<char, int> mapa;

    LL npr = 0;
    LL odg = 0;
    LL levi = 0;
    LL desni = s.size() - 1;

    for (char c : s)
    {
        mapa[c]++;
    }

    for (auto i : mapa)
    {
        if ((i.second % 2) == 1)
            npr++;
    }

    min = s.length() + 1;

    while (levi < desni)
    {
        LL l = levi, d = desni;

        while (s[l] != s[d])
        {
            d--;
        }

        if (l == d)
        {

            swap(s[d], s[d + 1]);

            if ((d + 1) > max)
                max = (d + 1);
            if (d < min)
                min = d;
            odg++;
            continue;
        }
        else
        {
            while (d < desni)
            {
                swap(s[d], s[d + 1]);
                if ((d + 1) > max)
                    max = (d + 1);
                if (d < min)
                    min = d;
                odg++;
                d++;
            }
        }
        desni--;
        levi++;
    }

    if ((max - min) + 1 > 0)
        cout << (max - min) + 1;
    else
        cout << 1;

    return 0;
}