#include <iostream>
#include <string>

using namespace std;

int main() {
	string s; cin >> s;
	long long b = 0, ans = 0;
	for (char c : s) {
		if (c == 'B') ++b;
		else ans += b;
	}
	cout << ans << endl;

	return 0;
}