Stack It I

View as PDF

Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type

Stack It I

You're nearly finished your charcuterie board, all you have to do is finish your towering tetrahedron of cheese balls in the middle.

You have N cheese balls, and you want to make as tall of a stack as possible. You want to stack the balls tetrahedrally, meaning that each layer is an increasingly shrinking equiltaterial triangle.

For example, a tetrahedron with height of 3 has 3 layers of cheese balls, and 6 + 3 + 1 = 10 balls in total.

When making your cheese ball tetrahedron, you don't want to leave any layers incomplete. It's okay if you have some cheese balls spare.

Given N cheese balls, what is the tallest tetrahedron you can make?

Input

Each test case with contain an a single integer N (1 \leq N \leq 10^{15}), the number of cheese balls you have at your disposal.

Output

For each test case, print the tallest tetrahedron you can make out of your input.

Example

Input
12
Output
3

With 12 cheese balls, you can make a tetrahedron of height 3 with 2 spare balls. It is not possible to make a tetrahedron of height 4.


Comments

There are no comments at the moment.