#include <bits/stdc++.h>
int main() {
  int n = 0, b[51] = {0}, i = 0, j = 0;
  long long int r = 0;
  char a[51] = {'\0'}, *p = a;
  scanf("%d", &n);
  scanf("%s", a);
  while (*(p + i) != '\0') {
    if (*(p + i) == 'R') b[j++] = 0;
    if (*(p + i) == 'B') b[j++] = 1;
    i++;
  }
  for (i = 0; i < n; i++) {
    r += pow(2, i) * b[i];
  }
  printf("%I64d", r);
  return 0;
}
