#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, sum = 0;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B') sum += pow(2, i);
  }
  cout << sum << endl;
}
