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 C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramB a = new ProgramB();
            a.main();//実行する

        }

    }

    class ProgramA
    {
        public void main()
        {
            //入力
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            int d = int.Parse(s[3]);


            if (Math.Abs(a-b)<= d && Math.Abs(c - b) <= d)
                Console.WriteLine("Yes");
            else if(Math.Abs(c - a) <= d)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力
            int x = int.Parse(Console.ReadLine());

            for (int i = x; i > 0; i--)
            {
                for(int j = 2; j <= Math.Sqrt(x);j++)
                {
                    if(i % j == 0)
                    {
                        int t = i;
                        while (t % j == 0)
                            t /= j;

                        if(t == 1)
                        {
                            Console.WriteLine(i);
                            return;
                        }
                    }
                }

            }


            Console.WriteLine(1);
        }

        
    }

    class ProgramC
    {
        public void main()
        {

            //入力
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');

            //最大公約数を求める
            long temp = gcd(long.Parse(s[0]), long.Parse(s[1]));
            for(int i = 2;i < s.Length;i++)
            {
                temp = gcd(temp, long.Parse(s[i]));
                
            }

            //答え出力
            Console.WriteLine(temp);

        }

        /*最大公約数を求める関数*/
        static long gcd(long p, long q)
        {
            if (p < q)
            {
                long temp = p;
                p = q;
                q = temp;
            }

            long r = 1;

            while (r != 0)
            {
                r = p % q;
                p = q;
                q = r;
            }

            return p;
        }
    }



    class ProgramD
    {
        public void main()
        {

            //入力
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long m = long.Parse(s[1]);
            string[] t = Console.ReadLine().Split(' ');
            int[] num = {2,5,5,4,5,6,3,7,6};
            int[] dp = new int[n + 1];
            int INF = -10000000;

            //動的計画で最大桁数を出す
            for (int i = 1; i <= n; i++)
                dp[i] = INF;

            dp[0] = 0;//初項
            for (int i = 0;i <= n;i++)
            {
                if (dp[i] == INF)
                    continue;
                for (int j = 0; j < m; j++)
                {
                    if(i + num[int.Parse(t[j])- 1] <= n)
                        dp[i + num[int.Parse(t[j]) - 1]] = Math.Max(dp[i + num[int.Parse(t[j]) - 1]], dp[i] + 1);
                }
            }

            int pos = (int)n;//位置記録
            //桁数分逆算して答え出力
            for(int i = 0;i < dp[n];i++)
            {

                int max = 0;
                int sub = 0;

                //一つ前の中で一番大きいものに移動する
                for (int j = 0; j < m; j++)
                {
                    if (pos - num[int.Parse(t[j]) - 1] >= 0)
                    {
                        if (dp[pos - num[int.Parse(t[j]) - 1]] == dp[pos] - 1)
                        {
                            if (max < int.Parse(t[j]))
                            {
                                max = int.Parse(t[j]);
                                sub = num[int.Parse(t[j]) - 1];
                            }
                        }
                    }
                }

                //最大値の出力して、位置を移動
                Console.Write(max);
                pos -= sub;

            }

        }
    }

   
}