Reincarnated as a Slime Researcher (Easy)

Given a starting integer K, repeatedly factor it into two factors at least 2, minimizing the maximum number of splits along any root to leaf path.

Medium5GreedyNumber theoryMathRecursionInterviewNo attempts yetTime limit0.5sMemory limit512 MB

Problem

Hi. My name is ntopia.

I used to be an ordinary guy in his twenties living on Earth. One day a stranger stabbed me on the street and I died. When I came to, I had dropped into another world. Here I seem to have become a slime researcher who studies nothing but slimes. I am working on a very important project. If it succeeds, I get to go back to the world I came from. Will you help me with it?

Every slime here holds slime energy, and the amount is a natural number of at least 22. I study how slime energy changes when a slime splits.

A split turns one slime into two. Take a slime with energy KK. Split it properly and you get a slime with energy AA and a slime with energy BB, where AA and BB are natural numbers of at least 22 and K=A×BK = A \times B always holds. Keep splitting and sooner or later you reach slimes that cannot be split.

The splitting technique is not perfect yet, so every split adds one scratch. Splitting a slime with TT scratches produces two slimes with T+1T + 1 scratches each.

A slime with energy 2424 and 11 scratch being split. It became a slime with energy 44 and 22 scratches and a slime with energy 66 and 22 scratches.

Right now I have a slime with slime energy KK and no scratches at all. I have to split it over and over until no slime that can still be split is left. Once everything is split, the slimes at the end carry some number of scratches. (Possibly none.) My goal is to choose the splits so that the largest scratch count among them is as small as possible.

Help me with my research. Please!

Input

The first line contains the energy KK (2K10000002 \le K \le 1\,000\,000) of the slime you start with.

Output

Print on one line the smallest possible value of the largest scratch count after the slime is split as far as it goes.

Hint

Start from a slime with energy 2424 and no scratches. Split it into a slime with energy 44 and a slime with energy 66, and both end up with 11 scratch.

The slime with energy 44 and 11 scratch splits into two slimes with energy 22 and 22 scratches.

The slime with energy 66 and 11 scratch splits into a slime with energy 22 and 22 scratches and a slime with energy 33 and 22 scratches.

After that no slime that can be split is left. The largest scratch count here is 22, and no other way of splitting brings it lower.