implicit none
integer :: x
integer :: b
integer :: a, z

read *,x

if (x <= 3) then
   print '(i0)',1
   stop
endif

a = 0
do b = 2, int(sqrt(real(x)))
   z = b * b
   if (z > x) then
      exit
   endif
   do while (z <= x)
      if (a < z) a = z
      z = z * b
   enddo
enddo

print '(i0)',a
stop
end  