#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long keta(long long n) {
  string s = to_string(n);
  long long num = s.size();
  return num;
}
const long long INF = 1LL << 60;
const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};
struct Edge {
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
using P = pair<long long, int>;
class UnionFind {
 public:
  vector<int> Parent;
  UnionFind(int n) { Parent = vector<int>(n, -1); }
  int root(int a) {
    if (Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }
  int size(int a) {
    a = root(a);
    return -Parent[a];
  }
  bool merge(int a, int b) {
    a = root(a);
    b = root(b);
    if (a == b) return false;
    if (a < b) swap(a, b);
    Parent[a] += Parent[b];
    Parent[b] = a;
    return true;
  }
  bool issame(int a, int b) { return root(a) == root(b); }
};
int main() {
  int n, x;
  string s;
  cin >> s;
  long long ans = 0;
  long long cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B')
      cnt++;
    else
      ans += cnt;
  }
  cout << ans << endl;
}
