PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000387. Căn bậc ba gần đúng (Pretty Good Cube Root)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Căn bậc ba gần đúng (Pretty Good Cube Root)

Pretty Good Cube Root

Version: Phuoc Hung OJ Extended

PHOJ practice edition. Its constraints, input/output format, examples and judging rules are specified below.

Problem Statement

Given a positive integer NN, find a nonnegative integer xx minimizing ∣x3−N∣|x^3-N|. If two values achieve the minimum difference, choose the larger one.

Input

One line contains a positive decimal integer NN without leading zeros.

Output

Print the required integer xx.

Subtasks

  • Subtask 1 (20 points): 1≤N<1091\le N<10^{9}.
  • Subtask 2 (30 points): 1≤N<10181\le N<10^{18}.
  • Subtask 3 (50 points): 1≤N<103001\le N<10^{300}.

Created examples

Input

27

Output

3

Explanation

For N=27N=27, choosing x=3x=3 gives 33=273^3=27. The difference is zero, the smallest possible.

Input

14

Output

2

Explanation

For N=14N=14, the adjacent cubes are 23=82^3=8 and 33=273^3=27. Their differences are 14−8=614-8=6 and 27−14=1327-14=13. Thus x=2x=2 is better, and more distant cubes cannot improve it.

Input

20

Output

3

Explanation

For N=20N=20, the adjacent cubes are 8 and 27. The differences are 20−8=1220-8=12 and 27−20=727-20=7. Choose x=3x=3 since 7 is smaller than 12.

Input

16

Output

2

Explanation

For N=16N=16, the adjacent cubes are 8 and 27, with differences 16−8=816-8=8 and 27−16=1127-16=11. Under the cube-distance criterion of this draft, choose 2.