#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long int a = 0;
  int count = 0;
  for (char& ch : s) {
    if (ch == 'B') a += pow(2, count);
    ++count;
  }
  cout << a;
  return 0;
}
