P2810 Catch the Thieves

Background

You know this: the security guards at a certain high school in Zhejiang are very diligent (sui) and meticulous (bian). But one day, a herd of cows (don’t ask me why) slipped into the campus and walked into the second cafeteria, stealing tasty dishes (never tried them). Now the headmaster is very angry and ordered the guards to investigate strictly. At this moment, *** walked by, and the hardworking and rigorous guards asked *** for help. *** was busy and handed the task to you. How about a cup of coffee first.

Description

karlven heard that while the guards were on duty playing games, they saw $4$ cows rolling out of the school gate (ate too much?). This breed of cow is very greedy and also orderly. How is that reflected? When stealing food they line up, and the amount eaten by each later cow is an **integer multiple (denote as $k$, $k>1$)** of the previous cow’s amount. Based on his experience, these cows can **eat at most $m$ tons** of food; once they **exceed it, they die** and turn to ashes. Therefore, a cow **will not** eat more than $m$ tons, and can only eat **one ton at a time**. If any cow cannot eat its required amount, it will attack its companion and then commit suicide. Now karlven does not tell you the value of $m$, and only tells you the number $n$ ($n \le 10^{15}$) of schemes in which the cows **can steal together and roll out safely together**. Please compute the value of $m$. If there are multiple answers, output the **smallest possible value**. If you cannot find any such $m$, output $-1$ and then file a complaint against the guards.

Input Format

A single integer $n$.

Output Format

Your computed answer, a single integer.

Explanation/Hint

Constraints: For $100\%$ of the testdata, $n \le 10^{15}$. Sample explanation: Sample #1: (1, 2, 4, 8). Sample #2: (1, 2, 4, 8), (1, 3, 9, 27), (2, 4, 8, 16), (2, 6, 18, 54), (3, 6, 12, 24), (4, 8, 16, 32), (5, 10, 20, 40), (6, 12, 24, 48). Translated by ChatGPT 5