#include <bits/stdc++.h>
int main() {
  long long n, i, sum = 0;
  char c;
  scanf("%I64d ", &n);
  for (i = 0; i < n; i++) {
    scanf("%c", &c);
    if (c == 'B') sum += (long long)pow(2, i);
  }
  printf("%I64d\n", sum);
  return 0;
}
