2018 Yonsei University Programming Contest

Given the total spark count N of a firework that bursts once then bursts again, find the branching factor K.

Easy3MathImplementationBrute forceBinary searchInterviewNo attempts yetTime limit1sMemory limit128 MB

Problem

After 2015, 2016 and 2017, the Yonsei University computer science programming contest is held again this year.

Dohyun was moved that the campus contest runs for a fourth year in a row, so he prepared a showy opening ceremony and was ready to pay for it himself.

What he wanted was fireworks. He thought everyone would love a firework that blows straight through the ceiling of lecture room A528. The firework he plans to order bursts like this.

  1. The single large spark made by the launched firework reaches a suitable height and splits into KK medium sparks in one burst.
  2. Each of the KK medium sparks splits again into KK small sparks and bursts.
  3. After that every spark dies out.

Dohyun tried to find a suitable firework, but the seller would not tell him the value of KK. The seller told him only the total number of sparks one firework makes, counting the first large spark together with all medium and small sparks. Dohyun never worked out which firework suited him, so he bought none.

He then promised one extra solved problem in this contest to any student who settles the question for him. To win the contest, take the total number of sparks a firework makes and find KK.

Input

The total number of sparks NN is given. (3N101013 \le N \le 10101)

Output

Print the value of KK. This value is guaranteed to be an integer, and impossible cases are not given as input.