import java.util.Scanner;

class Main{
	public static void main(String args[]){
		int x, a, b, c;
		int n = 1;
		c = 1;
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		if(x == 1){
			System.out.print(1);
			return;
		}
		for(int i = 2; i <= 32; i++){
			b = i;
          	c = i;
			while(c * b <= x){
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			}
		}
		System.out.print(n);
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String args[]){
		int x, a, b, c;
		int n = 1;
		c = 1;
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		if(x == 1){
			System.out.print(1);
			return;
		}
		for(int i = 2; i <= 32; i++){
			b = i;
          	c = i;
			while(c * b <= x){
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			}
		}
		System.out.print(n);
	}
} Main public static void main(String args[]){
		int x, a, b, c;
		int n = 1;
		c = 1;
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		if(x == 1){
			System.out.print(1);
			return;
		}
		for(int i = 2; i <= 32; i++){
			b = i;
          	c = i;
			while(c * b <= x){
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			}
		}
		System.out.print(n);
	} main {
		int x, a, b, c;
		int n = 1;
		c = 1;
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		if(x == 1){
			System.out.print(1);
			return;
		}
		for(int i = 2; i <= 32; i++){
			b = i;
          	c = i;
			while(c * b <= x){
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			}
		}
		System.out.print(n);
	} int x x a a b b c; c int n = 1; n 1 c = 1 c 1 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) x = sc.nextInt() x sc.nextInt() sc.nextInt sc if(x == 1){
			System.out.print(1);
			return;
		} x == 1 x 1 {
			System.out.print(1);
			return;
		} System.out.print(1) System.out.print System.out System System.out 1 return; for(int i = 2; i <= 32; i++){
			b = i;
          	c = i;
			while(c * b <= x){
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			}
		} int i = 2; int i = 2; i 2 i <= 32 i 32 i++ i++ i {
			b = i;
          	c = i;
			while(c * b <= x){
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			}
		} {
			b = i;
          	c = i;
			while(c * b <= x){
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			}
		} b = i b i c = i c i while(c * b <= x){
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			} c * b <= x c * b c b x {
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			} c *= b c b if(n <= c){
				  n = c;
			  } n <= c n c {
				  n = c;
			  } n = c n c System.out.print(n) System.out.print System.out System System.out n String args[] args
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		int x, a, b, c;
		int n = 1;
		c = 1;
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		if(x == 1){
			System.out.print(1);
			return;
		}
		for(int i = 2; i <= 32; i++){
			b = i;
          	c = i;
			while(c * b <= x){
              c *= b;
			  if(n <= c){
				  n = c;
			  }
			}
		}
		System.out.print(n);
	}
}
