program exp
implicit none
integer i,j,base,index
integer in,temp
read *, in ! 1<=in<=1000
base = 1
index =1
do i=1,sqrt(real(in))  ! Base of exponential
  do j=1, 9 ! Index of exponential, 2^10>1000 therefore j<=9
    if(i**j<in) then
      if(i**j>base**index) then
        base=i
        index = j
      end if
    end if
  end do
end do
print *, base**index
end program exp