#K456. Pyramid Brick Levels

    ID: 27789 Type: Default 1000ms 256MiB

Pyramid Brick Levels

Pyramid Brick Levels

You are given two integers n and k, where n represents the maximum potential number of levels of a pyramid, and k represents the total number of bricks available. Each level i of the pyramid requires exactly i bricks. In other words, to build L complete levels, you need a total of $$\sum_{i=1}^{L} i = \frac{L(L+1)}{2}$$ bricks.

Your task is to determine the maximum number of complete levels that can be built given the constraint of k bricks and the maximum level n.

Example: If n = 5 and k = 10, the first level requires 1 brick, the second level requires 2 bricks, the third level requires 3 bricks, and the fourth level requires 4 bricks. However, 1+2+3+4 = 10, so you can build exactly 4 levels. Building the 5th level would require 5 more bricks which are not available.

inputFormat

The input is given via stdin and contains two space-separated integers:

  • n: The maximum potential number of pyramid levels.
  • k: The number of bricks available.

You can assume that both numbers are positive integers.

outputFormat

Output a single integer via stdout representing the maximum number of complete pyramid levels that can be built with the given bricks.

## sample
5 15
5