program prob3
    implicit none
    integer :: x
    integer :: tmp, ans, i

    read(*,*) x

    ans = 1
    do i = 2, 34
        tmp = i * i
        do while(tmp <= x)
            ans = max(ans, tmp)
            tmp = tmp * i
        end do
    end do

    write(*,*) ans

    stop
contains
end program prob3