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

int brb, br;
string t;
int main(){
 cin>>t;
 for(int i = 0, j = t.size()-1; i<t.size()/2; i++, j--){
  if(t[i]=='b') brb++;
  if(t[j]=='b') brb++;
  if(brb>=1)br++;
  if(brb==2)break;
 }
 cout<<br<<endl;
return 0;}