#D. JIXMPII5J0gZSM0#[:[
JIXMPII5J0gZSM0#[:[
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Statement
Each evening after the dinner the SIS's students gather together to play the game of Sport Mafia.
For the tournament, Alya puts candies into the box, which will serve as a prize for a winner. To do that, she performs actions. The first action performed is to put a single candy into the box. For each of the remaining moves she can choose from two options:
- the first option, in case the box contains at least one candy, is to take exactly one candy out and eat it. This way the number of candies in the box decreased by ;
- the second option is to put candies in the box. In this case, Alya will put more candy, than she put in the previous time.
Thus, if the box is empty, then it can only use the second option.
For example, one possible sequence of Alya's actions look as follows:
- put one candy into the box;
- put two candies into the box;
- eat one candy from the box;
- eat one candy from the box;
- put three candies into the box;
- eat one candy from the box;
- put four candies into the box;
- eat one candy from the box;
- put five candies into the box;
This way she will perform actions, the number of candies at the end will be , while Alya will eat candies in total.
You know the total number of actions and the number of candies at the end . You need to find the total number of sweets Alya ate. That is the number of moves of the first option. It's guaranteed, that for the given and the answer always exists.
Please note, that during an action of the first option, Alya takes out and eats exactly one candy.
Format
Input
The first line contains two integers and ( ; ) — the total number of moves and the number of candies in the box at the end.
It's guaranteed, that for the given and the answer exists.
Output
Print a single integer — the number of candies, which Alya ate. Please note, that in this problem there aren't multiple possible answers — the answer is unique for any input data.
Sample
1 1
0
9 11
4
5 0
3
3 2
1
ShanghaiTech ACM 炸鱼杯
- 状态
- 已结束
- 规则
- OI
- 题目
- 46
- 开始于
- 2024-12-10 23:00
- 结束于
- 2024-12-15 13:00
- 持续时间
- 110 小时
- 主持人
- 参赛人数
- 112