program answer
  implicit none

  integer :: X, i, ans
  integer :: b(40)

  read(*,*) X

  if(X==1) then
     write(*,*) 1
     stop
  end if

  b(1)=4
  b(2)=8
  b(3)=16
  b(4)=32
  b(5)=64
  b(6)=128
  b(7)=256
  b(8)=512
  b(9)=9
  b(10)=27
  b(11)=81
  b(12)=243
  b(13)=729
  b(14)=25
  b(15)=125
  b(16)=625
  b(17)=49
  b(18)=343
  b(19)=121
  b(20)=169
  b(21)=289
  b(22)=361
  b(23)=529
  b(24)=841
  b(25)=961
  b(26)=36
  b(27)=216
  b(28)=100
  b(29)=1000
  b(30)=144
  b(31)=196
  b(32)=225
  b(33)=324
  b(34)=400
  b(35)=441
  b(36)=484
  b(37)=576
  b(38)=676
  b(39)=784
  b(40)=900
  

  ans=b(1)
  do i = 2, 40
     if(b(i)>ans.and.b(i)<=X) then
        ans = b(i)
     end if
  end do

  write(*,*) ans

  stop
 end program answer

  

; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEb = internal unnamed_addr global [40 x i32] undef
@_QQcl.655e356b84a103f2db11abfec58d9fa9 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5988/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.655e356b84a103f2db11abfec58d9fa9, i32 7)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i32, ptr %1, align 4, !tbaa !3
  %6 = icmp eq i32 %5, 1
  br i1 %6, label %7, label %12

7:                                                ; preds = %0
  %8 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.655e356b84a103f2db11abfec58d9fa9, i32 10)
  %9 = call i1 @_FortranAioOutputInteger32(ptr %8, i32 1)
  %10 = call i32 @_FortranAioEndIoStatement(ptr %8)
  %11 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

12:                                               ; preds = %0
  store i32 4, ptr @_QFEb, align 16, !tbaa !3
  store i32 8, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 1), align 4, !tbaa !3
  store i32 16, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 2), align 8, !tbaa !3
  store i32 32, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 3), align 4, !tbaa !3
  store i32 64, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 4), align 16, !tbaa !3
  store i32 128, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 5), align 4, !tbaa !3
  store i32 256, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 6), align 8, !tbaa !3
  store i32 512, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 7), align 4, !tbaa !3
  store i32 9, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 8), align 16, !tbaa !3
  store i32 27, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 9), align 4, !tbaa !3
  store i32 81, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 10), align 8, !tbaa !3
  store i32 243, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 11), align 4, !tbaa !3
  store i32 729, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 12), align 16, !tbaa !3
  store i32 25, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 13), align 4, !tbaa !3
  store i32 125, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 14), align 8, !tbaa !3
  store i32 625, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 15), align 4, !tbaa !3
  store i32 49, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 16), align 16, !tbaa !3
  store i32 343, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 17), align 4, !tbaa !3
  store i32 121, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 18), align 8, !tbaa !3
  store i32 169, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 19), align 4, !tbaa !3
  store i32 289, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 20), align 16, !tbaa !3
  store i32 361, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 21), align 4, !tbaa !3
  store i32 529, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 22), align 8, !tbaa !3
  store i32 841, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 23), align 4, !tbaa !3
  store i32 961, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 24), align 16, !tbaa !3
  store i32 36, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 25), align 4, !tbaa !3
  store i32 216, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 26), align 8, !tbaa !3
  store i32 100, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 27), align 4, !tbaa !3
  store i32 1000, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 28), align 16, !tbaa !3
  store i32 144, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 29), align 4, !tbaa !3
  store i32 196, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 30), align 8, !tbaa !3
  store i32 225, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 31), align 4, !tbaa !3
  store i32 324, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 32), align 16, !tbaa !3
  store i32 400, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 33), align 4, !tbaa !3
  store i32 441, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 34), align 8, !tbaa !3
  store i32 484, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 35), align 4, !tbaa !3
  store i32 576, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 36), align 16, !tbaa !3
  store i32 676, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 37), align 4, !tbaa !3
  store i32 784, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 38), align 8, !tbaa !3
  store i32 900, ptr getelementptr inbounds ([40 x i32], ptr @_QFEb, i64 0, i64 39), align 4, !tbaa !3
  br label %13

13:                                               ; preds = %13, %12
  %indvars.iv = phi i64 [ 2, %12 ], [ %indvars.iv.next.2, %13 ]
  %.07 = phi i32 [ 4, %12 ], [ %spec.select.2, %13 ]
  %14 = add nsw i64 %indvars.iv, -1
  %15 = getelementptr [40 x i32], ptr @_QFEb, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !3
  %17 = icmp sgt i32 %16, %.07
  %18 = icmp sle i32 %16, %5
  %19 = and i1 %17, %18
  %spec.select = select i1 %19, i32 %16, i32 %.07
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = getelementptr [40 x i32], ptr @_QFEb, i64 0, i64 %indvars.iv
  %21 = load i32, ptr %20, align 4, !tbaa !3
  %22 = icmp sgt i32 %21, %spec.select
  %23 = icmp sle i32 %21, %5
  %24 = and i1 %22, %23
  %spec.select.1 = select i1 %24, i32 %21, i32 %spec.select
  %25 = getelementptr [40 x i32], ptr @_QFEb, i64 0, i64 %indvars.iv.next
  %26 = load i32, ptr %25, align 4, !tbaa !3
  %27 = icmp sgt i32 %26, %spec.select.1
  %28 = icmp sle i32 %26, %5
  %29 = and i1 %27, %28
  %spec.select.2 = select i1 %29, i32 %26, i32 %spec.select.1
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %exitcond.not.2 = icmp eq i64 %indvars.iv.next.2, 41
  br i1 %exitcond.not.2, label %30, label %13

30:                                               ; preds = %13
  %31 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.655e356b84a103f2db11abfec58d9fa9, i32 63)
  %32 = call i1 @_FortranAioOutputInteger32(ptr %31, i32 %spec.select.2)
  %33 = call i32 @_FortranAioEndIoStatement(ptr %31)
  %34 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

attributes #0 = { noreturn }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
