import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;

void main() {
    int x = readln.chomp.to!(int);
    int[1001] arr;

    for (int i = 1; i <= x; i++) {
        for (int j = 2; j <= 100; j++) {
            int t = pow(i, j);
            if (t <= x) {
                arr[i] = max(arr[i], t);
            }
            else {
                break;
            }
        }
        arr[i] = max(arr[i - 1], arr[i]);
    }

    writeln(arr[x]);
}