#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n, sum = 0;
  char c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c == 'B') sum += pow(2, i);
  }
  cout << sum;
  return 0;
}
