#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  long long int res = 0, fact = 1;
  char c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c == 'B') res += (long long int)fact;
    fact = (long long int)(fact * 2);
  }
  cout << res << "\n";
}
int main() {
  solve();
  return 0;
}
