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