#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
long long n;
string s;
int main() {
  cin >> n;
  cin >> s;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'B') ans += 1LL << i;
  }
  cout << ans << endl;
  return 0;
}
