
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //99999は門番
        int[] check = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,99999};

        Scanner sc = new Scanner(System.in);
        int max  = sc.nextInt();

        for (int i = 0; i < check.length; i++) {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        }
    }

} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        //99999は門番
        int[] check = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,99999};

        Scanner sc = new Scanner(System.in);
        int max  = sc.nextInt();

        for (int i = 0; i < check.length; i++) {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        }
    }

} Main public static void main(String[] args) {
        //99999は門番
        int[] check = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,99999};

        Scanner sc = new Scanner(System.in);
        int max  = sc.nextInt();

        for (int i = 0; i < check.length; i++) {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        }
    } main {
        //99999は門番
        int[] check = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,99999};

        Scanner sc = new Scanner(System.in);
        int max  = sc.nextInt();

        for (int i = 0; i < check.length; i++) {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        }
    } int[] check = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,99999}; check {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,99999} 1 4 8 9 16 25 27 32 36 49 64 81 100 121 125 128 144 169 196 216 225 243 256 289 324 343 361 400 441 484 512 529 576 625 676 729 784 841 900 961 1000 99999 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int max  = sc.nextInt(); max sc.nextInt() sc.nextInt sc for (int i = 0; i < check.length; i++) {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        } int i = 0; int i = 0; i 0 i < check.length i check.length check check.length i++ i++ i {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        } {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        } if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            } max < check[i] max check[i] check i {
                System.out.println(check[i - 1]);
                return;
            } System.out.println(check[i - 1]) System.out.println System.out System System.out check[i - 1] check i - 1 i 1 return; String[] args args public class Main {
    public static void main(String[] args) {
        //99999は門番
        int[] check = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,99999};

        Scanner sc = new Scanner(System.in);
        int max  = sc.nextInt();

        for (int i = 0; i < check.length; i++) {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        }
    }

} public class Main {
    public static void main(String[] args) {
        //99999は門番
        int[] check = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,99999};

        Scanner sc = new Scanner(System.in);
        int max  = sc.nextInt();

        for (int i = 0; i < check.length; i++) {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        }
    }

} Main

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //99999は門番
        int[] check = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,99999};

        Scanner sc = new Scanner(System.in);
        int max  = sc.nextInt();

        for (int i = 0; i < check.length; i++) {
            if(max < check[i]){
                System.out.println(check[i - 1]);
                return;
            }
        }
    }

}
