#include <bits/stdc++.h>
using namespace std;
int main() {
  long long count = 0;
  char temp;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    if (temp == 'B') {
      if (i == 0) {
        count++;
      } else {
        count += pow(2, i);
      }
    }
  }
  cout << count << endl;
  return 0;
}
