Problem:
Score : 200 points

Problem Statement

You are given a positive integer X.
Find the largest perfect power that is at most X.
Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Constraints

1 ≤ X ≤ 1000

X is an integer.

Input

Input is given from Standard Input in the following format:

X

Output

Print the largest perfect power that is at most X.

Sample Input 1

10

Sample Output 1

9

There are four perfect powers that are at most 10: 1, 4, 8 and 9.
We should print the largest among them, 9.

Sample Input 2

1

Sample Output 2

1

Sample Input 3

999

Sample Output 3

961

Solution in Fortran (GNU Fortran 9.2.1) (judge verdict: Accepted)

program sample
  implicit none
  integer(8) :: i,j,x,y,count
  integer(8) :: a(41)
    
  read(*,*) x

  a(1) =1
  
  
  do i=2,9
     a(i) = 2**i
  end do
    
  do i=10,14
     a(i) = 3**(i-8)
  end do

  do i=15,17
     a(i) = 5**(i-13)
  end do
  do i=18,19
     a(i) =6**(i-16)
  end do

  do i=20,21
     a(i) = 7**(i-18)
  end do

  do i=22,23
     a(i) = 10**(i-20)
  end do

  do i=24,28
     a(i) = (i-13)**2
  end do

  do i=29,36
     a(i) = (i-12)**2
  end do

  a(37) = 26**2
  
  do i=38,41
     a(i)=(i-10)**2
  end do

  do i=1,41
     do j=i,41
        if (a(i)>a(j)) then
           y=a(i)
           a(i)=a(j)
           a(j)=y
        end if
     end do
  end do

  do i=1,41
     if (a(i) <= x) then
        count=a(i)
     end if
  end do

  write(*,*) count
  
  stop
end program sample