using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Scanner;
using static System.Math;

class Solver
{
    static void Main(string[] args) {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Solve();
        Console.Out.Flush();
    }

    static void Solve() {
        var X = Scan<int>();
        var max = 1;
        for (int i = 2; i * i < X; i++) {
            var n = i;
            var m = X / i ;
            while (n <= m) {
                n *= i;
            }
            max = Max(n, max);
        }
        Console.WriteLine(max);
    }
}

class Scanner
{
    const int BUFFER_SIZE = 1024;
    const char SPACE = ' ', BEGIN = '!', END = '~', ZERO = '0', NINE = '9'; 
    static readonly Stream stdin = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[BUFFER_SIZE];
    static int size, p;
    static bool isEof;

    [MethodImpl(256)]
    private static byte Read() {
        if (isEof) return default;
        if (p < size) return buffer[p++];
        p = 0;
        if ((size = stdin.Read(buffer, 0, BUFFER_SIZE)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    [MethodImpl(256)]
    private static char Next() {
        byte b;
        do b = Read();
        while (b < BEGIN || END < b);
        return (char) b;
    }
    [MethodImpl(256)]
    private static string Str() {
        var sb = new StringBuilder().Append(Next());
        for (var c = (char) Read(); BEGIN <= c && c <= END; c = (char) Read()) sb.Append(c);
        return sb.ToString();
    }
    [MethodImpl(256)]
    public static ReadOnlySpan<char> StrSpan() {
        var list = new List<char> {Next()};
        for (var c = (char) Read(); BEGIN <= c && c <= END; c = (char) Read()) list.Add(c);
        return list.AsSpan();
    }
    [MethodImpl(256)]
    private static int Int() {
        int tmp = Next() - ZERO;
        for (var c = (char) Read(); ZERO <= c && c <= NINE; c = (char) Read()) tmp = tmp * 10 + c - ZERO;
        return tmp;
    }
    [MethodImpl(256)]
    private static long Long() {
        long tmp = Next() - ZERO;
        for (var c = (char) Read(); ZERO <= c && c <= NINE; c = (char) Read()) tmp = tmp * 10 + c - ZERO;
        return tmp;
    }
    [MethodImpl(256)]
    private static double Double() => double.Parse(Str(), CultureInfo.InvariantCulture);
    [MethodImpl(256)]
    public static string ScanLine() {
        var sb = new StringBuilder();
        for (var c = Next(); SPACE <= c && c <= END; c = (char) Read()) sb.Append(c);
        return sb.ToString();
    }
    [MethodImpl(256)]
    public static T Scan<T>() 
        => default(T) switch 
            {int _ => (T) (object) Int(), long _ => (T) (object) Long(), string _ => (T) (object) Str(), _ => (T) (object) Double()};
    [MethodImpl(256)] public static (T, T) Dual<T>() => (Scan<T>(), Scan<T>());
    [MethodImpl(256)] public static (T, T, T) Tri<T>() => (Scan<T>(), Scan<T>(), Scan<T>());
    [MethodImpl(256)] public static (T, T, T, T) Quad<T>() => (Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>());
    [MethodImpl(256)] public static (T, T, T, T, T) Quint<T>() => (Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>());
    [MethodImpl(256)] public static (T1, T2) Scan<T1, T2>() => (Scan<T1>(), Scan<T2>());
    [MethodImpl(256)] public static (T1, T2, T3) Scan<T1, T2, T3>() => (Scan<T1>(), Scan<T2>(), Scan<T3>());
    [MethodImpl(256)] public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Scan<T1>(), Scan<T2>(), Scan<T3>(), Scan<T4>());
    [MethodImpl(256)] public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Scan<T1>(), Scan<T2>(), Scan<T3>(), Scan<T4>(), Scan<T5>());
    [MethodImpl(256)] public static (T1, T2, T3, T4, T5, T6) Scan<T1, T2, T3, T4, T5, T6>() => (Scan<T1>(), Scan<T2>(), Scan<T3>(), Scan<T4>(), Scan<T5>(), Scan<T6>());
}
static class ListExtention
{
    private abstract class Wrapper<T> { public readonly T[] Items; protected Wrapper(T[] items) => Items = items; }
    [MethodImpl(256)]
    public static Span<T> AsSpan<T>(this List<T> list) => Unsafe.As<Wrapper<T>>(list).Items.AsSpan(0, list.Count);
}

Measured memory_bytes: 23584