#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define debug(x) cout << #x << " = " << x << endl
#define pb push_back
#define F first
#define S second

int main() {
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);


    string s;
    int n, aux = 0, ans = 0, cantB = 0, i = 0;
    cin >> s;
    n = s.size();
    while(i < n){
        char c = s[i];
        if(c == 'B')cantB++;
        else if(cantB > 0){
            ans += cantB;
        }
        i++;
    }

    cout << ans << "\n";




}
