import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        
        long max = 0;
        long y = 0;
        for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        }
        
        System.out.println(max);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Map; Map java.util import java.util.HashMap; HashMap java.util public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        
        long max = 0;
        long y = 0;
        for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        }
        
        System.out.println(max);
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        
        long max = 0;
        long y = 0;
        for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        }
        
        System.out.println(max);
    } main {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        
        long max = 0;
        long y = 0;
        for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        }
        
        System.out.println(max);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int x = Integer.parseInt(br.readLine()); x Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br long max = 0; max 0 long y = 0; y 0 for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        } int i = 1; int i = 1; i 1 i <= x i x i++ i++ i {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        } {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        } for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            } int j = 2; int j = 2; j 2 j <= 1000 j 1000 j++ j++ j {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            } {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            } y = (long)Math.pow(i, j) y (long)Math.pow(i, j) Math.pow Math i j if (y <= x && y > max) max = y; y <= x && y > max y <= x y x y > max y max max = y max y 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) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        
        long max = 0;
        long y = 0;
        for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        }
        
        System.out.println(max);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        
        long max = 0;
        long y = 0;
        for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        }
        
        System.out.println(max);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        
        long max = 0;
        long y = 0;
        for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= 1000; j++) {
                y = (long)Math.pow(i, j);
                if (y <= x && y > max) max = y;
            }
        }
        
        System.out.println(max);
    }
}
