import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 0;
        boolean[] ok = new boolean[x+1];
        ok[1] = true;
        for(int i = 2;i <= x;i++){
            int v = i*i;
            while(v<=x){
                ok[v] = true;
                v *= i;
            }
        }

        for(int i = x;i >= 1;i--){
            if(ok[i]){
                System.out.println(i);
                break;
            }
        }
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 0;
        boolean[] ok = new boolean[x+1];
        ok[1] = true;
        for(int i = 2;i <= x;i++){
            int v = i*i;
            while(v<=x){
                ok[v] = true;
                v *= i;
            }
        }

        for(int i = x;i >= 1;i--){
            if(ok[i]){
                System.out.println(i);
                break;
            }
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 0;
        boolean[] ok = new boolean[x+1];
        ok[1] = true;
        for(int i = 2;i <= x;i++){
            int v = i*i;
            while(v<=x){
                ok[v] = true;
                v *= i;
            }
        }

        for(int i = x;i >= 1;i--){
            if(ok[i]){
                System.out.println(i);
                break;
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 0;
        boolean[] ok = new boolean[x+1];
        ok[1] = true;
        for(int i = 2;i <= x;i++){
            int v = i*i;
            while(v<=x){
                ok[v] = true;
                v *= i;
            }
        }

        for(int i = x;i >= 1;i--){
            if(ok[i]){
                System.out.println(i);
                break;
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int ans = 0; ans 0 boolean[] ok = new boolean[x+1]; ok new boolean[x+1] x+1 x 1 ok[1] = true ok[1] ok 1 true for(int i = 2;i <= x;i++){
            int v = i*i;
            while(v<=x){
                ok[v] = true;
                v *= i;
            }
        } int i = 2; int i = 2; i 2 i <= x i x i++ i++ i {
            int v = i*i;
            while(v<=x){
                ok[v] = true;
                v *= i;
            }
        } {
            int v = i*i;
            while(v<=x){
                ok[v] = true;
                v *= i;
            }
        } int v = i*i; v i*i i i while(v<=x){
                ok[v] = true;
                v *= i;
            } v<=x v x {
                ok[v] = true;
                v *= i;
            } ok[v] = true ok[v] ok v true v *= i v i for(int i = x;i >= 1;i--){
            if(ok[i]){
                System.out.println(i);
                break;
            }
        } int i = x; int i = x; i x i >= 1 i 1 i-- i-- i {
            if(ok[i]){
                System.out.println(i);
                break;
            }
        } {
            if(ok[i]){
                System.out.println(i);
                break;
            }
        } if(ok[i]){
                System.out.println(i);
                break;
            } ok[i] ok i {
                System.out.println(i);
                break;
            } System.out.println(i) System.out.println System.out System System.out i break; String[] args args
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 0;
        boolean[] ok = new boolean[x+1];
        ok[1] = true;
        for(int i = 2;i <= x;i++){
            int v = i*i;
            while(v<=x){
                ok[v] = true;
                v *= i;
            }
        }

        for(int i = x;i >= 1;i--){
            if(ok[i]){
                System.out.println(i);
                break;
            }
        }
    }
}