import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        long max = 0;
        if(X <= 3){
            System.out.println(1);
            return;
        }
        for(int i = 2;i*i <= X;i++){
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        }
        System.out.println(max);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        long max = 0;
        if(X <= 3){
            System.out.println(1);
            return;
        }
        for(int i = 2;i*i <= X;i++){
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        }
        System.out.println(max);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        long max = 0;
        if(X <= 3){
            System.out.println(1);
            return;
        }
        for(int i = 2;i*i <= X;i++){
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        }
        System.out.println(max);
    } main {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        long max = 0;
        if(X <= 3){
            System.out.println(1);
            return;
        }
        for(int i = 2;i*i <= X;i++){
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        }
        System.out.println(max);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc long max = 0; max 0 if(X <= 3){
            System.out.println(1);
            return;
        } X <= 3 X 3 {
            System.out.println(1);
            return;
        } System.out.println(1) System.out.println System.out System System.out 1 return; for(int i = 2;i*i <= X;i++){
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        } int i = 2; int i = 2; i 2 i*i <= X i*i i i X i++ i++ i {
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        } {
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        } long power = i; power i while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            } true {
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            } power = power*i power power*i power i if(power > X){
                    power = power / i;
                    break;
                } power > X power X {
                    power = power / i;
                    break;
                } power = power / i power power / i power i break; max = Math.max(max,power) max Math.max(max,power) Math.max Math max power System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        long max = 0;
        if(X <= 3){
            System.out.println(1);
            return;
        }
        for(int i = 2;i*i <= X;i++){
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        }
        System.out.println(max);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        long max = 0;
        if(X <= 3){
            System.out.println(1);
            return;
        }
        for(int i = 2;i*i <= X;i++){
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        }
        System.out.println(max);
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        long max = 0;
        if(X <= 3){
            System.out.println(1);
            return;
        }
        for(int i = 2;i*i <= X;i++){
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        }
        System.out.println(max);
    }
}
