/* -*- coding: utf-8 -*- * * 559.cc: No.559 swapAB列 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ /* typedef */ /* global variables */ /* subroutines */ /* main */ int main() { string s; cin >> s; int c = 0, b = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'A') c += b; else b++; } printf("%d\n", c); return 0; }