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