#include #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair ; using pll = pair; constexpr int INF = 1e9; constexpr ll LINF = 1e18; constexpr int MOD = 1000000007; int main(){ string s; cin >> s; int ans = 0; int b = 0; rep(i,s.size()){ if(s[i] == 'B') ++b; else ans += b; } cout << ans << endl; return 0; }