#include #include using namespace std; int main() { string s; cin >> s; int cnt = 0, ans = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'A')ans += cnt; else cnt++; }cout << ans << endl; }