#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long q = 0, w = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') q = q * 10 + ch - '0', ch = getchar();
  return q * w;
}
const long long N = 1e3 + 5;
long long n, i, j;
string input;
unsigned long long s[N], cnt;
int main() {
  n = read();
  s[1] = 1;
  for (i = 2; i <= n; i++) s[i] = (s[i - 1] * 2);
  cin >> input;
  for (i = 0; i < input.size(); i++) {
    if (input[i] == 'B') cnt += s[(i + 1)];
  }
  cout << cnt << endl;
  return 0;
}
