#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 *, char *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int main() {
  char *input;
  while (1) {
    scanf("%s", input);
    if (strcmp(input, "#") == 0)
      break;
    int input_len = strlen(input);
    int ones = 0;
    for (int i = 0; i < input_len - 1; ++i) {
      if (input[i] == '1')
        ones++;
    }
    if (input[input_len - 1] == 'e') {
      if (ones % 2 == 0)
        input[input_len - 1] = '0';
      else
        input[input_len - 1] = '1';
    } else {
      if (ones % 2 == 0)
        input[input_len - 1] = '1';
      else
        input[input_len - 1] = '0';
    }
    printf("%s\n", input);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    117e <main+0x3e>
jmp    1289 <main+0x149>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11da <main+0x9a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    11c7 <main+0x87>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11cc <main+0x8c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <main+0x58>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x65,%eax
jne    1234 <main+0xf4>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    121e <main+0xde>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x30,(%rax,%rcx,1)
jmp    122f <main+0xef>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    1274 <main+0x134>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    125e <main+0x11e>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    126f <main+0x12f>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x30,(%rax,%rcx,1)
jmp    1274 <main+0x134>
mov    -0x10(%rbp),%rsi
lea    0xd86(%rip),%rdi
call   1040 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1050 <scanf@plt>
lea    0xebf(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1152 <main+0x22>
xor    %eax,%eax
pop    %rcx
ret
call   1030 <strlen@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"#\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %0, %79
%7 = load i8*, i8** %2
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %2
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %6
br label %82
13: ; preds = %6
%14 = load i8*, i8** %2
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %16
16: ; preds = %33, %13
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 1
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %36
21: ; preds = %16
%22 = load i8*, i8** %2
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 49
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %32
32: ; preds = %29, %21
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %16
36: ; preds = %16
%37 = load i8*, i8** %2
%38 = load i32, i32* %3
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 101
br i1 %44, label %45, label %62
45: ; preds = %36
%46 = load i32, i32* %4
%47 = srem i32 %46, 2
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %45
%50 = load i8*, i8** %2
%51 = load i32, i32* %3
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %50, i64 %53
store i8 48, i8* %54
br label %61
55: ; preds = %45
%56 = load i8*, i8** %2
%57 = load i32, i32* %3
%58 = sub nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %56, i64 %59
store i8 49, i8* %60
br label %61
61: ; preds = %55, %49
br label %79
62: ; preds = %36
%63 = load i32, i32* %4
%64 = srem i32 %63, 2
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %72
66: ; preds = %62
%67 = load i8*, i8** %2
%68 = load i32, i32* %3
%69 = sub nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
store i8 49, i8* %71
br label %78
72: ; preds = %62
%73 = load i8*, i8** %2
%74 = load i32, i32* %3
%75 = sub nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
store i8 48, i8* %77
br label %78
78: ; preds = %72, %66
br label %79
79: ; preds = %78, %61
%80 = load i8*, i8** %2
%81 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %80)
br label %6
82: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"#\00"
define i32 @main() {
%1 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* undef)
%2 = tail call i64 @strcmp(i8* undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @strlen(i8* undef)
unreachable
6: ; preds = %0
ret i32 0
}