#include <stdio.h>
#include <iostream>
#include <string>
#include <time.h>


using namespace std;

int main(void) {

	int X=0;
	int num=1;
	cin >> X;
	int grab = 1;
	

	/*for (int i = 0; num <= X; i++) {
		num *= 2;
	}
	num /= 2;

	grab = num;*/


	
	for (int j = 2; j < 32; j++) {
		num = j;
		for (int i = 0; num <= X; i++) {
			num *= j;
		}
		num /= j;

		if (grab <= num && num <= X )
			grab = num;

	}



	/*	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 3;
	}
	num /= 3;

	if(grab <= num)
	grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *=5;
	}
	num /= 5;

	if (grab <= num)
	grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 6;
	}
	num /= 6;

	if (grab <= num)
		grab = num;

	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 7;
	}
	num /= 7;

	if (grab <= num)
		grab = num;

	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 10;
	}
	num /= 10;

	if (grab <= num)
		grab = num;

	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 11;
	}
	num /= 11;

	if (grab <= num)
		grab = num;

	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 12;
	}
	num /= 12;

	if (grab <= num)
		grab = num;

	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 13;
	}
	num /= 13;

	if (grab <= num)
		grab = num;

	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 14;
	}
	num /= 14;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 15;
	}
	num /= 15;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 16;
	}
	num /= 16;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 17;
	}
	num /= 17;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 18;
	}
	num /= 18;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 19;
	}
	num /= 19;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 20;
	}
	num /= 20;

	if (grab <= num)
		grab = num;
	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 21;
	}
	num /= 21;

	if (grab <= num)
		grab = num;
	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 22;
	}
	num /= 22;

	if (grab <= num)
		grab = num;



	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 23;
	}
	num /= 23;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 24;
	}
	num /= 24;

	if (grab <= num)
		grab = num;
	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 26;
	}
	num /= 26;

	if (grab <= num)
		grab = num;
	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 28;
	}
	num /= 28;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 29;
	}
	num /= 29;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 30;
	}
	num /= 30;

	if (grab <= num)
		grab = num;


	num = 1;
	for (int i = 0; num <= X; i++) {
		num *= 31;
	}
	num /= 31;

	if (grab <= num)
		grab = num;*/



	if (grab == 2 || grab == 3)
		cout << 1 << endl;
	else if(grab == 5 || grab == 6 || grab ==7)
		cout << 4 << endl;
	else if (grab ==10 || grab == 11 || grab == 12 || grab == 13 || grab == 14 || grab == 15)
		cout << 9 << endl;
	else if (grab == 17 || grab == 18 || grab == 19 || grab == 20 || grab == 21 || grab == 22 || grab == 23 || grab == 24||grab ==25)
		cout << 16 << endl;
	else if (grab == 26 || grab == 27)
		cout << 25 << endl;
	else if (grab == 28 || grab == 29 || grab == 30 || grab == 31 || grab == 32)
		cout << 27 << endl;
	else
		cout << grab << endl;
}



Measured memory_bytes: 256