#include #include int main(){ char str[13]; int i, len, state = 0, cnt = 0, cnt_B = 0; scanf("%s", str); len = strlen(str); for(i = 0; i < len; i++){ if(state == 0){ if(str[i] == 'B'){ state = 1; cnt_B++; continue; } }else if(state == 1){ if(str[i] == 'A'){ cnt += cnt_B; continue; }else if(str[i] == 'B'){ cnt_B++; } } } printf("%d\n", cnt); return 0; }