#include using namespace std; int solve(string s) { int ret = 0; for(int i = 0; i < s.size(); i++) { if(s[i] == 'B') ret += i; } return ret; } string x; int main() { cin >> x; int ret = solve(x); sort(x.begin(), x.end()); cout << solve(x) - ret << endl; return 0; }