/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>
#include<string>
using namespace std;

int main()
{
    string T,rec;
    int duzina,i,j,b1=0,b2=0,minduz=0;
    cin>>T;
    duzina=T.length();
    bool palindrom=true;
    for(i=0; i<duzina/2; i++)
    {
        if(T[i]!=T[duzina-i-1])
        {
            palindrom=false;
        }
    }
    rec=T;
    for(i=0; i<=duzina; i++)
    {
        if(rec[i]=='b')
        {b1=i;
        cout<<i<<endl;
        }
        if(rec[i]=='b' && i!=b1)
        {
            b2=i;
            cout<<i<<endl;
        }
    }
    minduz=duzina-(b2+b1);
    if(palindrom==true)
    {cout<<1;}
    else    
    {cout<<minduz-1;}
    return 0;
}