#include <bits/stdc++.h>
using namespace std;
long long res;
string s;
int n;
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B') res |= (1ll << i);
  }
  cout << res << endl;
  return 0;
}
