program ABC097B
	integer(8)::X,i,j
	integer(8)::result=1
	
	read(5,*)X
	
	do i=2,9
		do j=2,31
			if(j**i>X)then
				exit
			else if(j**i>result)then
				result=j**i
			end if
		end do
	end do
	
	print'(i0)',result
end program ABC097B
