#include <bits/stdc++.h>
using namespace std;
stack<char> stk, stk1;
long long Power(long long e, int x) {
  long long res = 1;
  for (int i = 0; i < x; i++) res *= e;
  return res;
}
int main() {
  long long n, cnt = 0, R = 0, B = 0;
  char ch;
  int check = 0, s = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ch;
    stk1.push(ch);
    if (ch == 'R')
      R++;
    else
      B++;
  }
  for (int i = 0; i < n; i++) {
    stk.push(stk1.top());
    stk1.pop();
  }
  while (R < n) {
    check = 0;
    s = 0;
    while (1) {
      if (stk.top() == 'R') {
        stk.pop();
        R--;
      } else if (stk.top() == 'B') {
        stk.pop();
        B--;
        stk.push('R');
        R++;
        check = 1;
        cnt++;
        break;
      }
    }
    if (check == 1) {
      int res = n - (R + B);
      for (int i = 0; i < res; i++) {
        stk.push('R');
        R++;
      }
      cnt += Power(2, res) - 1;
    } else if (check == 0) {
      while (stk.top() == 'B') {
        stk.pop();
        B--;
        s++;
      }
      cnt += Power(2, s) - 1;
    }
    for (int i = 0; i < s; i++) {
      stk.push('R');
      R++;
    }
  }
  cout << cnt;
  return 0;
}
