#include <iostream>

using namespace std;

int main()
{
    int br1 = -1, br2 = -1;
    string niska;
    cin >> niska;
    int d = niska.length();
    int j;
    for (j = 0; j < d; j++)
    {
        if (niska[j] != niska[d - j - 1])
        {
            break;
        }
    }
    for (int i = j; i < d; i++)
    {
        if (niska[i] == 'b' && br1 == -1)
        {
            br1 = i;
        }
        else if (niska[i] == 'b')
        {
            br2 = i;
            break;
        }
    }
    br2 = d - br2 - 1;
    if (br1 + 1 <= d/2 + d%2 && br2 + 1 <= d/2 + d%2)
    {
        cout << abs(br1 - br2) + 1;
    }
    else
    {
        cout << d/2 - (br1+1<=d/2?br1:br2) + 1 + d%2;
    }

    return 0;
}