#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define llong long long int main() { string s; cin >> s; bool is_a = false; int lower = 0; int upper = s.length() / 2; while(upper > lower) { int middle = (upper + lower + 1) / 2; int alen = 0; int blen = 0; bool flg = false; rep(i, middle*2) { if(s[i] == 'A') alen++; else blen++; } flg |= alen == blen; for(int i=1; i