import java.util.Scanner;

import javax.sql.rowset.serial.SerialArray;

public class Main {

		public static void main(String[] args){
			
			Scanner sc = new Scanner(System.in);

			
			int X = sc.nextInt();

			int ans = 0;
			int max = 0;
			double d = Math.sqrt(X);
			
			int wki = (int) Math.floor(d);
			
			for(int i = 1;i <= wki;i++){
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			}
			
			if (max == 0){
			    System.out.println(X);
			    return ;
				
			}
		    System.out.println(max);
		    return ;
		}
			
} import java.util.Scanner; Scanner java.util import javax.sql.rowset.serial.SerialArray; SerialArray javax.sql.rowset.serial public class Main {

		public static void main(String[] args){
			
			Scanner sc = new Scanner(System.in);

			
			int X = sc.nextInt();

			int ans = 0;
			int max = 0;
			double d = Math.sqrt(X);
			
			int wki = (int) Math.floor(d);
			
			for(int i = 1;i <= wki;i++){
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			}
			
			if (max == 0){
			    System.out.println(X);
			    return ;
				
			}
		    System.out.println(max);
		    return ;
		}
			
} Main public static void main(String[] args){
			
			Scanner sc = new Scanner(System.in);

			
			int X = sc.nextInt();

			int ans = 0;
			int max = 0;
			double d = Math.sqrt(X);
			
			int wki = (int) Math.floor(d);
			
			for(int i = 1;i <= wki;i++){
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			}
			
			if (max == 0){
			    System.out.println(X);
			    return ;
				
			}
		    System.out.println(max);
		    return ;
		} main {
			
			Scanner sc = new Scanner(System.in);

			
			int X = sc.nextInt();

			int ans = 0;
			int max = 0;
			double d = Math.sqrt(X);
			
			int wki = (int) Math.floor(d);
			
			for(int i = 1;i <= wki;i++){
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			}
			
			if (max == 0){
			    System.out.println(X);
			    return ;
				
			}
		    System.out.println(max);
		    return ;
		} 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 int max = 0; max 0 double d = Math.sqrt(X); d Math.sqrt(X) Math.sqrt Math X int wki = (int) Math.floor(d); wki (int) Math.floor(d) Math.floor Math d for(int i = 1;i <= wki;i++){
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			} int i = 1; int i = 1; i 1 i <= wki i wki i++ i++ i {
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			} {
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			} for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				} int j = 1; int j = 1; j 1 j <= wki j wki j++ j++ j {
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				} {
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				} ans = (int) Math.pow(i, j) ans (int) Math.pow(i, j) Math.pow Math i j if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					} X < ans X ans {
						j = wki;
					} j = wki j wki {
						if(max < ans){
							max = ans;
						}
					} if(max < ans){
							max = ans;
						} max < ans max ans {
							max = ans;
						} max = ans max ans if (max == 0){
			    System.out.println(X);
			    return ;
				
			} max == 0 max 0 {
			    System.out.println(X);
			    return ;
				
			} System.out.println(X) System.out.println System.out System System.out X return ; System.out.println(max) System.out.println System.out System System.out max return ; String[] args args public class Main {

		public static void main(String[] args){
			
			Scanner sc = new Scanner(System.in);

			
			int X = sc.nextInt();

			int ans = 0;
			int max = 0;
			double d = Math.sqrt(X);
			
			int wki = (int) Math.floor(d);
			
			for(int i = 1;i <= wki;i++){
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			}
			
			if (max == 0){
			    System.out.println(X);
			    return ;
				
			}
		    System.out.println(max);
		    return ;
		}
			
} public class Main {

		public static void main(String[] args){
			
			Scanner sc = new Scanner(System.in);

			
			int X = sc.nextInt();

			int ans = 0;
			int max = 0;
			double d = Math.sqrt(X);
			
			int wki = (int) Math.floor(d);
			
			for(int i = 1;i <= wki;i++){
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			}
			
			if (max == 0){
			    System.out.println(X);
			    return ;
				
			}
		    System.out.println(max);
		    return ;
		}
			
} Main
import java.util.Scanner;

import javax.sql.rowset.serial.SerialArray;

public class Main {

		public static void main(String[] args){
			
			Scanner sc = new Scanner(System.in);

			
			int X = sc.nextInt();

			int ans = 0;
			int max = 0;
			double d = Math.sqrt(X);
			
			int wki = (int) Math.floor(d);
			
			for(int i = 1;i <= wki;i++){
				for(int j = 1;j <= wki;j++){
					ans = (int) Math.pow(i, j);
					if(X < ans ) {
						j = wki;
					}else{
						if(max < ans){
							max = ans;
						}
					}
				}
			}
			
			if (max == 0){
			    System.out.println(X);
			    return ;
				
			}
		    System.out.println(max);
		    return ;
		}
			
}
