#include <bits/stdc++.h>
int n;
int main() {
  while (scanf("%d", &n) != EOF) {
    int i, j;
    char ball[54];
    long long unsigned ope = 0;
    long long unsigned tmp;
    scanf("%s", ball);
    for (i = 0; i < n; i++) {
      tmp = 1;
      if ('B' == ball[i]) {
        for (j = 0; j < i; j++) tmp *= 2;
        ope += tmp;
      }
    }
    printf("%I64u\n", ope);
  }
  return 0;
}
