#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 res = 0, cnt = s.size() - 1; for (int i = s.size() - 1; i >= 1; i--) if (s[i] == 'B') { res += abs(i - cnt); cnt--; } cout << res; }