using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace practice1
{
    class Program
    {
        static void Main(string[] args)
        {
            int number = int.Parse(Console.ReadLine());
            int max = 0;
            
            for(int i = number; i > 0; i--)
            {
                if (Bekizyousuu_Check(i))
                {
                    max = i;
                    break;
                }
            }

            MYCP.PrintNumber(max);

        }

        public static bool Bekizyousuu_Check(int number)
        {
            if (number == 1) return true;

            int i, copy;
            

            for (i = 2; i < number; i++)
            {
                copy = number;
                while (copy % i == 0)
                {
                    copy /= i;
                }

                if (copy == 1) return true;
            }

            return false;
        }

        
    }

    class MYCP
    {
        //標準出力の後改行する
        public static void Println(string str)
        {
            Console.WriteLine(str);
        }

        //標準出力の後改行しない
        public static void Print(string str)
        {
            Console.Write(str);
        }


        //int変数を標準出力する
        public static void PrintNumber(long number)
        {
            Console.WriteLine("" + number);
        }

        //あまり意味はない
        private static string MyScanf()
        {
            return Console.ReadLine();
        }

        //文字列を配列化して返す
        public static string[] MyScanfSplit()
        {
            return MyScanf().Split();
        }


        //double変数をソートする
        public static void MyDoubleSort(double[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            double a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }

        //int変数をソートする
        public static void MyLongSort(int[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            int a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }

        //指定された個数分数字を読み取る
        public static int[] ReadNumbers(long number)
        {
            int[] a = new int[number];
            string[] buff = MyScanfSplit();
            for (long i = 0; i < number; i++)
            {
                a[i] = int.Parse(buff[i]);
            }

            return a;
        }
    }
}


Measured memory_bytes: 11092