#include <bits/stdc++.h>
using namespace std;
stack<int> s;
int n;
char ch[100];
int num_R;
int size0;
long long time0;
long long dp[100];
int main() {
  scanf("%d", &n);
  scanf("%s", &ch[1]);
  dp[1] = 1;
  for (int k = 2; k <= n; k++) dp[k] = 2 * dp[k - 1] + 1;
  for (int k = 1; k <= n; k++) {
    if (ch[k] == 'B') time0 += dp[k - 1] + 1;
    while (ch[k + 1] == 'R') k++;
  }
  printf("%lld", time0);
  return 0;
}
