#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long x = 1, ans = 0;
  while (n--) {
    char a;
    cin >> a;
    if (a == 'B') ans += x;
    x *= 2;
  }
  cout << ans << endl;
  return 0;
}
