Question
Cinema Time

Ram lives in Delhi. Delhi can be represented as a straight line with Ram's house at point 0 on this line. There is an infinite number of subway stations in Delhi, numbered by positive integers. The first station is located at point 1 and for each i ≥ 1, the distance between stations i and i+1 is equal to i+1. (Station i+1 is always located at a higher coordinate than station i, i.e., the subway stations are located at points 1, 3, 6, 10, 15 etc.)
Subway trains in Delhi allow Ram to move between any pair of adjacent stations in one minute, regardless of the distance between them. Ram can also move by walking; his walking speed is one unit of distance in one minute. Ram can enter or exit the subway at any station.Ram has decided to go to the cinema. The only cinema in Delhi is located at point X. (Note that the cinema can be placed at the same point as a subway station.) Help Ram determine the minimum possible time required to get to the cinema from his house.

Input
The only line of input contains an integer X.

Constraints:
1 ≤ X ≤ 109
Output
Return an integer denoting the minimum possible travel time.
Example
Sample Input:
9
Sample Output:
5
Explanation
Ram will walk from x = 0 to x = 1 in one minute, then he will enter the subway and move from station 1 (at x = 1) to station 2 (at x = 3) in one minute, then from station 2 to station 3 (at x = 6) in one minute, from station 3 to station 4 (at x = 10) in one minute, and finally, he will walk from x = 10 to x = 9 in one minute, which makes the total travel time 5 minutes.

Online