#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  long long ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    ans <<= 1;
    if (S[i] == 'B') ans++;
  }
  cout << ans << "\n";
  return 0;
}
