#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 */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, char *);
int strlen(char *);
int main() {
  int cur, next, len, i;
  char str[1001];
  scanf("%d %s", &cur, str);
  len = strlen(str);
  for (i = 0; i < len; i++) {
    if (str[i] == 'L') {
      if (cur & 1)
        cur++;
      cur /= 2;
    } else {
      cur = cur * 2 + 11;
    }
  }
  printf("\n%d", cur);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x400(%rbp),%rdx
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x400(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11da <main+0xaa>
movslq -0x14(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0x4c,%eax
jne    11bb <main+0x8b>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a8 <main+0x78>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    11c7 <main+0x97>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
add    $0xb,%eax
mov    %eax,-0x8(%rbp)
jmp    11cc <main+0x9c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <main+0x3f>
mov    -0x8(%rbp),%esi
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x400,%rsp
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdx
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    0xc(%rsp),%esi
test   %eax,%eax
jle    119b <main+0x6b>
mov    %eax,%eax
xor    %ecx,%ecx
jmp    117e <main+0x4e>
nopw   0x0(%rax,%rax,1)
add    %esi,%esi
add    $0xb,%esi
add    $0x1,%rcx
cmp    %rcx,%rax
je     1197 <main+0x67>
cmpb   $0x4c,0x10(%rsp,%rcx,1)
jne    1170 <main+0x40>
mov    %esi,%edx
and    $0x1,%edx
add    %esi,%edx
mov    %edx,%esi
shr    $0x1f,%esi
add    %edx,%esi
sar    %esi
jmp    1175 <main+0x45>
mov    %esi,0xc(%rsp)
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
ret

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

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