#include #include #include #include using namespace std; int find_B(string S) { for (int i = 0; i < S.size(); i++) { if (S[i] == 'B') return i; } return -1; } int main() { string S; cin >> S; vector B_locations; int B_counts = 0; if (S.size() == 1) { cout << 0 << endl; return 0; } for (int i = 0; i < S.size(); ++i) { if (S[i] == 'B') { B_locations.push_back(i); ++B_counts; } } sort(B_locations.begin(), B_locations.end(), greater()); int answer = 0; for (int i = 0; i < B_locations.size(); ++i) { answer += S.size() - i - B_locations[i] - 1; } cout << answer << endl; return 0; }