#include <bits/stdc++.h>
using namespace std;
template <class T>
const T& max(const T& a, const T& b, const T& c) {
  return max(a, max(b, c));
}
template <class T>
const T& min(const T& a, const T& b, const T& c) {
  return min(a, min(b, c));
}
long long stoi(string& str) {
  istringstream second(str);
  long long i;
  second >> i;
  return i;
}
string itos(long long i) {
  stringstream second;
  second << i;
  return second.str();
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long poww(long long a, long long b) {
  long long res = 1;
  for (int i = 1; i <= b; i++) res *= a;
  return res;
}
long long sumOfDigs(string s) {
  long long sum = 0;
  for (int i = 0; i < s.length(); i++) sum += s[i] - '0';
  return sum;
}
long long sumOfDigs(long long n) {
  return (n < 10 ? n : n % 10 + sumOfDigs(n / 10));
}
long long mod = poww(10, 9) + 7;
int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
using namespace std;
void t() { freopen("test.txt", "r", stdin); }
long long a[100];
long long f(int n) {
  if (a[n]) {
    return a[n];
  }
  long long sum = 1;
  for (int i = 1; i <= n - 1; i++) {
    if (!a[i]) a[i] = f(i);
    sum += a[i];
  }
  a[n] = sum;
  return sum;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    char c;
    cin >> c;
    if (c == 'B') v.push_back(i);
  }
  long long sum = 0;
  for (int i = 0; i < v.size(); i++) sum += f(v[i]);
  cout << sum << endl;
  return 0;
}
