program exp
	implicit none
	integer :: y, c, i
	integer :: x

	read(*,*) x
	if ( x==1 ) then
    	write(*,*) 1
        stop
    end if
    
   	c = 1
	do i = 1, x
		do y = 2, x
			if (i**y <= x .and. i**y > c) then
				c = i ** y
			end if
		end do
	end do
	
	write(*,'(i0)') c
stop
end program exp