program beki
  implicit none

  integer :: x, n, p, b

  read(*,*) x

  n = 1
  if (x < 4 ) then
     n = 1
  else
     do b = 2, x-1
        p = 2
        do while ( b**p <= x )
          
           if ( n < b**p ) then
              n = b**P
           end if
           p = p + 1
        end do
     end do
  end if
  write(*,*) n
     
  stop
end program beki
  