import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(br.readLine());
		int max = 0;
		for(int i = 1; i < 32; i++){
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		}
		System.out.println(max);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java import java.math.*; math.* java public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(br.readLine());
		int max = 0;
		for(int i = 1; i < 32; i++){
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		}
		System.out.println(max);
	}
} Main public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(br.readLine());
		int max = 0;
		for(int i = 1; i < 32; i++){
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		}
		System.out.println(max);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(br.readLine());
		int max = 0;
		for(int i = 1; i < 32; i++){
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		}
		System.out.println(max);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int max = 0; max 0 for(int i = 1; i < 32; i++){
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		} int i = 1; int i = 1; i 1 i < 32 i 32 i++ i++ i {
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		} {
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		} int m = i; m i for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			} int j = 2; int j = 2; j 2 j < 10 j 10 j++ j++ j {
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			} {
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			} m = m * i m m * i m i if(max<=m && m<=n)
					max = m; max<=m && m<=n max<=m max m m<=n m n max = m max m if(m>n)
					break; m>n m n break; if(max<=m && m<=n)
				max = m; max<=m && m<=n max<=m max m m<=n m n max = m max m 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 IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(br.readLine());
		int max = 0;
		for(int i = 1; i < 32; i++){
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		}
		System.out.println(max);
	}
} public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(br.readLine());
		int max = 0;
		for(int i = 1; i < 32; i++){
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		}
		System.out.println(max);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(br.readLine());
		int max = 0;
		for(int i = 1; i < 32; i++){
			int m = i;
			for(int j = 2; j < 10; j++){
				m = m * i;
				if(max<=m && m<=n)
					max = m;
				if(m>n)
					break;
			}
			if(max<=m && m<=n)
				max = m;
		}
		System.out.println(max);
	}
}