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

int main()
{
    int br = 0, b1 = -1, b2, r, r1, r2, r3;
    string t, s;
    cin >> t;
    s = t;
    int n = t.size();

    for(int i = 0; i < (n-1); i++){
        if(t[i] == 'b'){
            if(b1 == -1)
                b1 = i;
            else
                b2 = i;
        }
    }
    reverse(t.begin(),t.end());
    r1 = n - b2;
    if(s == t)
        cout << 1;
    else if(r1 == b1)
        cout << 1;
    else if(r1 > b1){
        r = r1-b1;
        cout << r;}
    else if(b1 > r1){
        r = b1-r1+2;
        cout << r;}

    return 0;
}