Imports System
Imports System.Collections.Generic
class p
    shared sub main()
        dim n = Integer.Parse(Console.ReadLine())
        dim hs as new HashSet(of Integer)
        for i as Integer = 1 To 32
            for j as Integer = 2 To 32
                dim t = Math.Pow(i, j)
                ' dim t = i ^ j
                if t <= n then
                    hs.Add(t)
                else
                    exit for
                end if
            next
        next
        Console.WriteLine(hs.Max())
    end sub
end class