#include<bits/stdc++.h>
using namespace std;
string s;
stack<char>op;
int main()
{
cin>>s;
int len=s.size();
for(int j=1;j<=100000;j++)
{
for(int i=0;i<len;i++)
{
if(op.empty())
{
op.push(s[i]);
}
else
{
if(op.top()!=s[i])
{
op.push(s[i]);
}
else
{
op.pop();
}
}
}
if(op.empty())
{
len/=2;
}
}
cout<<len<<endl;
return 0;
}