#include <bits/stdc++.h>
using namespace std;
long long n, ans;
char s[1000001];
int main() {
  scanf("%d%s", &n, s);
  for (int i = 0; i < n; i++)
    if (s[i] == 'B') ans += ((long long)1 << i);
  cout << ans;
  return 0;
}
