#include <bits/stdc++.h> using namespace std; int main() { string S; int cnt; int a_cnt; cin >> S; int n = S.length(); cnt = 0; a_cnt = 0; for(int i = 0; i < n; i++){ if(S[i] == 'A'){ cnt += i - a_cnt; a_cnt++; } } cout << cnt << endl; return 0; }