#include using namespace std; typedef long long ll; #define int ll string s; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s; int n = s.size(); int res = 0, tmp = 0, cnt = 0; for (int i = n - 1; i >= 0; i--) if (s[i] == 'B') { tmp = i; break; } for (int i = tmp; i >= 0; i--) if (s[i] == 'B') { res += (tmp - i - cnt); cnt++; } cout << res; }