#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ pow(int, int);
int /*<<< orphan*/ printf(char *, unsigned long long);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char const *argv[]) {
  int n;
  char s[100];
  unsigned long long ans = 0;
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B')
      ans += pow(2, i);
  };
  printf("%I64d\n", ans);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x88(%rbp)
lea    0xea5(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11dd <main+0xad>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x42,%eax
jne    11c4 <main+0x94>
mov    -0x8c(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
add    -0x88(%rbp),%rax
mov    %rax,-0x88(%rbp)
jmp    11c9 <main+0x99>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1182 <main+0x52>
mov    -0x88(%rbp),%rsi
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xec2(%rip),%rdi
xor    %r14d,%r14d
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xeaf(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1198 <main+0x68>
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    117c <main+0x4c>
nop
add    $0x1,%rbx
movslq %eax,%rcx
cmp    %rcx,%rbx
jge    1198 <main+0x68>
cmpb   $0x42,0x10(%rsp,%rbx,1)
jne    1170 <main+0x40>
mov    $0x2,%edi
mov    %ebx,%esi
call   1050 <pow@plt>
add    %rax,%r14
mov    0xc(%rsp),%eax
jmp    1170 <main+0x40>
lea    0xe67(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [7 x i8] c"%I64d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i32 0, i32* %9
br label %13
13: ; preds = %30, %2
%14 = load i32, i32* %9
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %33
17: ; preds = %13
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 66
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = load i32, i32* %9
%26 = call i64 @pow(i32 2, i32 %25)
%27 = load i64, i64* %8
%28 = add i64 %27, %26
store i64 %28, i64* %8
br label %29
29: ; preds = %24, %17
br label %30
30: ; preds = %29
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
br label %13
33: ; preds = %13
%34 = load i64, i64* %8
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [7 x i8] c"%I64d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %26, %2
%12 = phi i64 [ 0, %2 ], [ %28, %26 ]
%13 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %12)
ret i32 0
14: ; preds = %2, %26
%15 = phi i32 [ %27, %26 ], [ %9, %2 ]
%16 = phi i64 [ %29, %26 ], [ 0, %2 ]
%17 = phi i64 [ %28, %26 ], [ 0, %2 ]
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %16
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 66
br i1 %20, label %21, label %26
21: ; preds = %14
%22 = trunc i64 %16 to i32
%23 = call i64 @pow(i32 2, i32 %22)
%24 = add i64 %23, %17
%25 = load i32, i32* %3
br label %26
26: ; preds = %14, %21
%27 = phi i32 [ %25, %21 ], [ %15, %14 ]
%28 = phi i64 [ %24, %21 ], [ %17, %14 ]
%29 = add nuw nsw i64 %16, 1
%30 = sext i32 %27 to i64
%31 = icmp slt i64 %29, %30
br i1 %31, label %14, label %11
}