program main
	implicit none
    integer(8)::x,i,j,ans
    
    read(*,*)x
    ans=0
    
    do i=1,x
    	do j=1,x
        	if(i**j<=x .and i**j>ans)then
            	ans=i**j
            end if
        end do
    end do
    stop
end program main
