#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 alen = 0; int blen = 0; int result = 0; for(char c: s) { if(c == 'A') { if(!is_a) alen = 0; alen += 1; } else { if(is_a) blen = 0; blen += 1; } result = max(result, min(alen, blen) * 2); is_a = c == 'A'; } cout << result << "\n"; }