program main
    implicit none
    integer(8) X, i, j, ans
	read(*, *) X
	ans = 0
	do i = 1, 50
	    do j = 2, 20
			if(i**j < 1 .or. i**j > 1000) then
				exit
		    else if(i**j <= X) then
			    ans = i**j
			end if
		end do
	end do
	write(*, *) ans
end program main