eolymp
bolt
Try our new interface for solving problems

Jump

Little Maggie is standing at the bottom of a long flight of stairs. The bottom of the stairs has number $0$, the bottommost step has number $1$, the next step has number $2$, and so on. The staircase is so long that Maggie is guaranteed not to reach its top. Maggie will now perform $n$ consecutive actions. The actions are numbered $1$ through $n$, in order. When performing action $X$, Maggie chooses between two options: either he does nothing, or she jumps exactly $X$ steps up the stairs. In other words, if Maggie starts performing action $X$ standing on step $Y$, she will end it either on step $Y$, or on step $Y + X$. For example, if $n = 3$, Maggie will make three consecutive choices: whether or not to jump $1$ step upwards, $2$ steps upwards, and then $3$ steps upwards. One of the steps is broken. The number of this step is $badStep$. Maggie cannot jump onto this step. \InputFile You are given the integers $n$ $(1 ≤ n ≤ 2000)$ and $badStep$ $(1 ≤ badStep ≤ 4000000)$. \OutputFile Compute and print the number of the topmost step that can be reached by Maggie.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2 2
Output example #1
3