#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  scanf("%d", &n);
  cin >> s;
  long long ans = 0, powerC = 1;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B') {
      ans += powerC;
    }
    powerC *= 2;
  }
  cout << ans;
  return 0;
}
