Олимпиадный тренинг

Задача 44658. Endless Jenga


Gromozeka and Alice came up with the rules of the game of endless Jenga.
In endless Jenga, each turn consists of one of two actions of the player's choice:

  • if there is at least one bar in the tower, then you can pull out and remove from the tower exactly one bar (the number of bars in the tower decreases by 1);
  • put on the tower the number of bars 1 more than the last time before this.
The first move always places one block into an empty tower. Formally speaking, after the first move, the tower consists of one bar. If after some move the tower turned out to be empty (it does not have a single bar), then a bar can only be placed in such a tower. Alice and Gromozeka have an infinite number of bars to install on the tower.

For example, you can perform the following sequence of actions while playing:

1) install one bar on the tower;
2) install two bars on the tower;
3) remove one block from the tower;
4) remove one block from the tower;
5) install three bars on the tower;
6) remove one block from the tower;
7) install four bars on the tower;
8) remove one block from the tower;
9) install five bars on the tower.

After 9 moves, the number of bars in the tower will eventually be 11, and during the game 4 bars were removed from the tower.

It is known that Alice and Gromozeka made n moves in the invented game, and after all the moves made, the number of bars in the tower was equal to k. Find the total number of bars removed by Alice and Gromozeka from the tower in all n moves. It is guaranteed that given n and k answer exists.

 

Input

The first line of the input contains two integers n and (1<=n<=109 ; 0<=k<=109) - the total number of moves and the number of bars in the tower after n moves. It is guaranteed that for the given  n and k answer exists.


Output

Print a single integer - the number of bars that Alice and Gromozeka pulled out together during the game. Please note that there cannot be multiple correct answers in this problem - the answer is uniquely determined by the input data.
 

 
Examples
# Input Output
1
1 1
0
2
9 11
4
3
50
3
4
3 2
1