// yukicoder: No.559 swapAB列 // 2019.4.20 bal4u #include char S[15], *p = S; int main() { int c, ans; scanf("%s", S); ans = c = 0; while (*p) { if (*p++ == 'A') ans += c; else c++; } printf("%d\n", ans); return 0; }