#include <bits/stdc++.h>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int index1, index2;
	bool prvi = true;
	int n = s.size();
	bool palindrom = true;
	bool paran;
	int indx1, indx2;
	for (int i = 0; i < n; i++)
	if(s[i]!=s[n-1-i])
	palindrom = false;
	if(palindrom ==false)
	{
		for (int i = 0; i < n; i++)
		{
			if(prvi && s[i]=='b')
			{
				prvi =false;
				index1 = i;
			}
			else if(!prvi && s[i]=='b')
			{
				index2 = i;
				break;
			}
		}
		indx1 = n-1-index2;
		indx2 = n-1-index1;
		cout << min(abs(index1-indx1),abs(index2-indx2))+1;
	}
	else cout << 1;
	return 0;
}