#K59707. Tallest Pyramid with Pots
Tallest Pyramid with Pots
Tallest Pyramid with Pots
You are given an integer n representing the number of pots available. Your task is to determine the height h of the tallest pyramid that can be built using these pots. In the pyramid, the first level uses 1 pot, the second level uses 2 pots, the third level uses 3 pots, and so on. The total number of pots required for a pyramid of height h is given by the formula:
$$\frac{h(h+1)}{2} \le n$$
Find the maximum possible height h such that the sum of the first h natural numbers does not exceed n.
inputFormat
The input is given via stdin and consists of a single line containing an integer n (0 ≤ n ≤ 10^9) which represents the number of available pots.
outputFormat
Output the maximum height of the pyramid that can be built with the given number of pots on stdout.## sample
14
4