import java.util.*;
import static java.lang.Math.*;

public class Main {
	
	public static void main(String... args) {
		System.out.println(calcExpMax(scanInt()));
	}
	
	private static final int MAX = (int) sqrt(1000d) + 1;
	
	private static int calcExpMax(int X) {
		int max = 1;
		for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		}
		return max;
	}

	
	private static final Scanner SC = new Scanner(System.in);

	private static int scanInt() {
		return SC.nextInt();
	}

	private static  String scanString() {
		return SC.next();
	}
} import java.util.*; util.* java import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; public class Main {
	
	public static void main(String... args) {
		System.out.println(calcExpMax(scanInt()));
	}
	
	private static final int MAX = (int) sqrt(1000d) + 1;
	
	private static int calcExpMax(int X) {
		int max = 1;
		for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		}
		return max;
	}

	
	private static final Scanner SC = new Scanner(System.in);

	private static int scanInt() {
		return SC.nextInt();
	}

	private static  String scanString() {
		return SC.next();
	}
} Main private static final int MAX = (int) sqrt(1000d) + 1; MAX (int) sqrt(1000d) + 1 (int) sqrt(1000d) sqrt 1000d 1 private static final Scanner SC = new Scanner(System.in); SC new Scanner(System.in) public static void main(String... args) {
		System.out.println(calcExpMax(scanInt()));
	} main {
		System.out.println(calcExpMax(scanInt()));
	} System.out.println(calcExpMax(scanInt())) System.out.println System.out System System.out calcExpMax(scanInt()) calcExpMax scanInt() scanInt String... args args private static int calcExpMax(int X) {
		int max = 1;
		for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		}
		return max;
	} calcExpMax {
		int max = 1;
		for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		}
		return max;
	} int max = 1; max 1 for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		} int i = 2; int i = 2; i 2 i < MAX i MAX ++i ++i i {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		} {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		} int pow = i; pow i for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			} int j = 2; int j = 2; j 2 j < 9 j 9 ++j ++j j {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			} {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			} pow *= i pow i if (X < pow) {
					break;
				} X < pow X pow {
					break;
				} break; if (max < pow) {
					max = pow;
				} max < pow max pow {
					max = pow;
				} max = pow max pow return max; max int X X private static int scanInt() {
		return SC.nextInt();
	} scanInt {
		return SC.nextInt();
	} return SC.nextInt(); SC.nextInt() SC.nextInt SC private static  String scanString() {
		return SC.next();
	} scanString {
		return SC.next();
	} return SC.next(); SC.next() SC.next SC public class Main {
	
	public static void main(String... args) {
		System.out.println(calcExpMax(scanInt()));
	}
	
	private static final int MAX = (int) sqrt(1000d) + 1;
	
	private static int calcExpMax(int X) {
		int max = 1;
		for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		}
		return max;
	}

	
	private static final Scanner SC = new Scanner(System.in);

	private static int scanInt() {
		return SC.nextInt();
	}

	private static  String scanString() {
		return SC.next();
	}
} public class Main {
	
	public static void main(String... args) {
		System.out.println(calcExpMax(scanInt()));
	}
	
	private static final int MAX = (int) sqrt(1000d) + 1;
	
	private static int calcExpMax(int X) {
		int max = 1;
		for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		}
		return max;
	}

	
	private static final Scanner SC = new Scanner(System.in);

	private static int scanInt() {
		return SC.nextInt();
	}

	private static  String scanString() {
		return SC.next();
	}
} Main
import java.util.*;
import static java.lang.Math.*;

public class Main {
	
	public static void main(String... args) {
		System.out.println(calcExpMax(scanInt()));
	}
	
	private static final int MAX = (int) sqrt(1000d) + 1;
	
	private static int calcExpMax(int X) {
		int max = 1;
		for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		}
		return max;
	}

	
	private static final Scanner SC = new Scanner(System.in);

	private static int scanInt() {
		return SC.nextInt();
	}

	private static  String scanString() {
		return SC.next();
	}
}
