defmodule Main do
  def solve(prev, x, num, n) when x <= n and x != 1 do
  	solve(prev * num, x * num, num, n)
  end
  def solve(prev, x, num, n) do
  	if prev == num and prev != 1 do
      0
    else
      prev
    end
  end
  
  
  def main do
    n = IO.gets("") |> String.trim |> String.to_integer
    numbers = 1..n
    numbers = Enum.to_list(numbers)
	IO.puts(Enum.map(numbers, fn x -> solve(1, x, x, n) end) |> Enum.filter(fn(x) -> x <= n end) |> Enum.max)
  end
end
