#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*/ baseConversion(char *, int, int);
scalar_t__ isPalindrome(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, base, sign;
  char s[30] = {0};
  scanf("%d", &n);
  for (++n;; ++n) {
    sign = 0;
    for (base = 2; base <= 10; ++base) {
      memset(s, 0, 30);
      baseConversion(s, n, base);
      if (isPalindrome(s))
        if (++sign >= 2)
          break;
    }
    if (sign >= 2) {
      printf("%d\n", n);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
lea    0xe8a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jg     1201 <main+0xb1>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <baseConversion@plt>
lea    -0x30(%rbp),%rdi
call   1060 <isPalindrome@plt>
cmp    $0x0,%rax
je     11ee <main+0x9e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmp    $0x2,%eax
jl     11e9 <main+0x99>
jmp    1201 <main+0xb1>
jmp    11ee <main+0x9e>
jmp    11f3 <main+0xa3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x46>
cmpl   $0x2,-0x10(%rbp)
jl     121f <main+0xcf>
mov    -0x8(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1040 <printf@plt>
jmp    1232 <main+0xe2>
jmp    1224 <main+0xd4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1188 <main+0x38>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x1e(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe90(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0x10(%rsp),%r14
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
addl   $0x1,0xc(%rsp)
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <baseConversion@plt>
mov    %r14,%rdi
call   1060 <isPalindrome@plt>
mov    %rax,%rbx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0x3,%edx
call   1030 <baseConversion@plt>
mov    %r14,%rdi
call   1060 <isPalindrome@plt>
mov    %rax,%rcx
or     %rbx,%rcx
sete   %r15b
test   %rax,%rax
je     1200 <main+0xb0>
test   %rbx,%rbx
jne    139a <main+0x24a>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0x4,%edx
call   1030 <baseConversion@plt>
mov    %r14,%rdi
call   1060 <isPalindrome@plt>
test   %rax,%rax
sete   %bl
mov    %ebx,%eax
or     %r15b,%al
cmp    $0x1,%al
jne    139a <main+0x24a>
and    %r15b,%bl
mov    %ebx,%eax
xor    $0x1,%al
movzbl %al,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0x5,%edx
call   1030 <baseConversion@plt>
mov    %r14,%rdi
call   1060 <isPalindrome@plt>
test   %rax,%rax
sete   %al
cmovne %r12d,%ebp
or     %bl,%al
cmp    $0x1,%al
jne    139a <main+0x24a>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0x6,%edx
call   1030 <baseConversion@plt>
mov    %r14,%rdi
call   1060 <isPalindrome@plt>
test   %rax,%rax
je     12bb <main+0x16b>
test   %ebp,%ebp
mov    $0x1,%ebp
jne    139a <main+0x24a>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0x7,%edx
call   1030 <baseConversion@plt>
mov    %r14,%rdi
call   1060 <isPalindrome@plt>
test   %rax,%rax
je     12f5 <main+0x1a5>
test   %ebp,%ebp
mov    $0x1,%ebp
jne    139a <main+0x24a>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0x8,%edx
call   1030 <baseConversion@plt>
mov    %r14,%rdi
call   1060 <isPalindrome@plt>
test   %rax,%rax
je     132b <main+0x1db>
test   %ebp,%ebp
mov    $0x1,%ebp
jne    139a <main+0x24a>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0x9,%edx
call   1030 <baseConversion@plt>
mov    %r14,%rdi
call   1060 <isPalindrome@plt>
test   %rax,%rax
je     1361 <main+0x211>
test   %ebp,%ebp
mov    $0x1,%ebp
jne    139a <main+0x24a>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1030 <baseConversion@plt>
mov    %r14,%rdi
call   1060 <isPalindrome@plt>
test   %rax,%rax
je     1190 <main+0x40>
test   %ebp,%ebp
je     1190 <main+0x40>
mov    0xc(%rsp),%esi
lea    0xc5e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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