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