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