import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

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

   String nyuA=sc.nextLine();
int X=Integer.parseInt(nyuA);

int ans=1;

for(int b=2;b<=X;b++){
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
}
System.out.println(ans);
}

}
 import java.io.*; io.* java import java.util.*; util.* java import java.math.BigInteger; BigInteger java.math public class Main {

static long[] list=new long[87];

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

   String nyuA=sc.nextLine();
int X=Integer.parseInt(nyuA);

int ans=1;

for(int b=2;b<=X;b++){
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
}
System.out.println(ans);
}

} Main static long[] list=new long[87]; list new long[87] 87 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

   String nyuA=sc.nextLine();
int X=Integer.parseInt(nyuA);

int ans=1;

for(int b=2;b<=X;b++){
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
}
System.out.println(ans);
} main {
		Scanner sc = new Scanner(System.in);

   String nyuA=sc.nextLine();
int X=Integer.parseInt(nyuA);

int ans=1;

for(int b=2;b<=X;b++){
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
}
System.out.println(ans);
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String nyuA=sc.nextLine(); nyuA sc.nextLine() sc.nextLine sc int X=Integer.parseInt(nyuA); X Integer.parseInt(nyuA) Integer.parseInt Integer nyuA int ans=1; ans 1 for(int b=2;b<=X;b++){
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
} int b=2; int b=2; b 2 b<=X b X b++ b++ b {
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
} {
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
} int power=b*b; power b*b b b for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
} int p=2; int p=2; p 2 p++ p++ p {
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
} {
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
} if(power>X)break; power>X power X break; ans=Math.max(ans,power) ans Math.max(ans,power) Math.max Math ans power power*=b power b System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

static long[] list=new long[87];

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

   String nyuA=sc.nextLine();
int X=Integer.parseInt(nyuA);

int ans=1;

for(int b=2;b<=X;b++){
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
}
System.out.println(ans);
}

} public class Main {

static long[] list=new long[87];

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

   String nyuA=sc.nextLine();
int X=Integer.parseInt(nyuA);

int ans=1;

for(int b=2;b<=X;b++){
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
}
System.out.println(ans);
}

} Main
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

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

   String nyuA=sc.nextLine();
int X=Integer.parseInt(nyuA);

int ans=1;

for(int b=2;b<=X;b++){
int power=b*b;
for(int p=2;;p++){
if(power>X)break;
ans=Math.max(ans,power);
power*=b;
}
}
System.out.println(ans);
}

}

