#include<iostream>
using namespace std;

int main(){
string rec;
cin>>rec;
int n,a;
n=rec.size();
int i=0,b;
while(i<n){
if(rec[i]=='b'){b=i;break;}
i++;
}
i=0;
while(i<n){
if(rec[n-i]=='b'&&n-i!=b){a=i;break;}
i++;
}
b=a-b;
if(b<0)b=-b;
if(b!=0)b++;
cout<<b;
}