#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__ floor(int);
int log10(double);
double pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int n, p, x;
  double p1;
  long long i, j;
  for (;;) {
    scanf("%de%d", &n, &p);
    if (n == 0 && p == 0)
      break;
    if (n == 0)
      printf("0\n");
    else {
      p1 = pow(10.0, (double)p);
      x = (int)floor(log10(n * p1) / log10(2.0));
      i = (long long int)pow(2.0, (double)x);
      j = (long long int)((n * p1) - i) * 2 + 1;
      printf("%lld\n", j);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    118c <main+0x3c>
cmpl   $0x0,-0xc(%rbp)
jne    118c <main+0x3c>
jmp    1263 <main+0x113>
cmpl   $0x0,-0x8(%rbp)
jne    11a9 <main+0x59>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125e <main+0x10e>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe52(%rip),%xmm0
call   1050 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1060 <log10@plt>
mov    %eax,-0x2c(%rbp)
movsd  0xe26(%rip),%xmm0
call   1060 <log10@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1070 <floor@plt>
mov    %eax,-0x10(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe02(%rip),%xmm0
call   1050 <pow@plt>
cvttsd2si %xmm0,%rax
mov    %rax,-0x20(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
cvtsi2sdq -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
shl    $0x1,%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115f <main+0xf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe93(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1060 <scanf@plt>
mov    0x8(%rsp),%edx
test   %edx,%edx
sete   %cl
mov    0xc(%rsp),%eax
or     %eax,%edx
jne    11b6 <main+0x46>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe67(%rip),%r14
lea    0xe54(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xc(%rsp),%rbx
lea    0xe49(%rip),%r13
jmp    1296 <main+0x126>
nopw   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xe11(%rip),%xmm0
call   1070 <pow@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1080 <log10@plt>
mov    %eax,%ebp
movsd  0xdee(%rip),%xmm0
call   1080 <log10@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1090 <floor@plt>
movsd  0xddb(%rip),%xmm0
mov    %eax,%edi
call   1030 <ldexp@plt>
cvttsd2si %xmm0,%rax
xorps  %xmm0,%xmm0
cvtsi2sdl 0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
mulsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
lea    (%rax,%rax,1),%rsi
add    $0x1,%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
mov    0x8(%rsp),%edx
test   %edx,%edx
sete   %cl
mov    0xc(%rsp),%eax
or     %eax,%edx
je     11a5 <main+0x35>
test   $0x1,%cl
je     11e0 <main+0x70>
mov    %r14,%rdi
call   1040 <puts@plt>
jmp    1273 <main+0x103>

LLVM IR (-O0):
@.str = [6 x i8] c"%de%d\00"
@.str.1 = [3 x i8] c"0\0A\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
br label %8
8: ; preds = %50, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
br label %51
16: ; preds = %12, %8
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %50
21: ; preds = %16
%22 = load i32, i32* %3
%23 = sitofp i32 %22 to double
%24 = call double @pow(double 1.000000e+01, double %23)
store double %24, double* %5
%25 = load i32, i32* %2
%26 = sitofp i32 %25 to double
%27 = load double, double* %5
%28 = fmul double %26, %27
%29 = call i32 @log10(double %28)
%30 = call i32 @log10(double 2.000000e+00)
%31 = sdiv i32 %29, %30
%32 = call i64 @floor(i32 %31)
%33 = trunc i64 %32 to i32
store i32 %33, i32* %4
%34 = load i32, i32* %4
%35 = sitofp i32 %34 to double
%36 = call double @pow(double 2.000000e+00, double %35)
%37 = fptosi double %36 to i64
store i64 %37, i64* %6
%38 = load i32, i32* %2
%39 = sitofp i32 %38 to double
%40 = load double, double* %5
%41 = load i64, i64* %6
%42 = sitofp i64 %41 to double
%43 = fneg double %42
%44 = call double @llvm.fmuladd.f64(double %39, double %40, double %43)
%45 = fptosi double %44 to i64
%46 = mul nsw i64 %45, 2
%47 = add nsw i64 %46, 1
store i64 %47, i64* %7
%48 = load i64, i64* %7
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %48)
br label %50
50: ; preds = %21, %19
br label %8
51: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%de%d\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
@str = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %45, label %11
11: ; preds = %0, %38
%12 = phi i32 [ %42, %38 ], [ %8, %0 ]
%13 = phi i1 [ %41, %38 ], [ %7, %0 ]
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %38
16: ; preds = %11
%17 = sitofp i32 %12 to double
%18 = call double @pow(double 1.000000e+01, double %17)
%19 = load i32, i32* %1
%20 = sitofp i32 %19 to double
%21 = fmul double %18, %20
%22 = call i32 @log10(double %21)
%23 = call i32 @log10(double 2.000000e+00)
%24 = sdiv i32 %22, %23
%25 = call i64 @floor(i32 %24)
%26 = trunc i64 %25 to i32
%27 = call double @ldexp(double 1.000000e+00, i32 %26)
%28 = fptosi double %27 to i64
%29 = load i32, i32* %1
%30 = sitofp i32 %29 to double
%31 = sitofp i64 %28 to double
%32 = fneg double %31
%33 = call double @llvm.fmuladd.f64(double %30, double %18, double %32)
%34 = fptosi double %33 to i64
%35 = shl nsw i64 %34, 1
%36 = or i64 %35, 1
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %36)
br label %38
38: ; preds = %16, %14
%39 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%40 = load i32, i32* %1
%41 = icmp eq i32 %40, 0
%42 = load i32, i32* %2
%43 = icmp eq i32 %42, 0
%44 = select i1 %41, i1 %43, i1 false
br i1 %44, label %45, label %11
45: ; preds = %38, %0
ret i32 0
}