4297: 安东与童话

内存限制:256 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:8 通过:4

题目描述

        安东喜欢听童话,尤其是安东最好的朋友丹尼克讲童话的时候。现在丹尼克给安东讲了一个童话:

很久很久以前,有一个皇帝。他非常富有,有很多谷物。一天,他下令建一个巨大的谷仓来存放他所有的谷物。最好的建筑工人花了三天三夜建造那个谷仓。但是他们忽略了,谷仓里还有一个小洞,每天都有麻雀从里面通过。一只麻雀飞到这里,吃了一粒谷物,飞走了……”

发生在童话里更完整的说法下。在第一天开始的时候,能容纳n粒谷物的谷仓已经满了。然后,每天(从第一天开始)都会发生以下事情:

            · m粒谷物被带到谷仓。如果m粒不适合谷仓谷仓满了,不适合的谷物就带回来(在这个问题中我们可以假设不适合谷仓的谷物不考虑)。

            · 麻雀来吃谷物。第i天有i麻雀来,第一天有一只麻雀来,第二天有两只麻雀来,以此类推。每只麻雀吃一粒。如果谷仓是空的,麻雀什么也不吃。

安东厌倦了听丹尼克描述每一只吃谷仓谷物的麻雀。安东不知道童话什么时候结束,所以他让你确定,哪一天谷仓会第一次变空。帮助安东,写一个程序,确定那是第几天

Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:
"Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to build a huge barn to put there all his grain. Best builders were building that barn for three days and three nights. But they overlooked and there remained a little hole in the barn, from which every day sparrows came through. Here flew a sparrow, took a grain and flew away..."
More formally, the following takes place in the fairy tale. At the beginning of the first day the barn with the capacity of n grains was full. Then, every day (starting with the first day) the following happens:
  • m grains are brought to the barn. If m grains doesn't fit to the barn, the barn becomes full and the grains that doesn't fit are brought back (in this problem we can assume that the grains that doesn't fit to the barn are not taken into account).
  • Sparrows come and eat grain. In the i-th day i sparrows come, that is on the first day one sparrow come, on the second day two sparrows come and so on. Every sparrow eats one grain. If the barn is empty, a sparrow eats nothing.
Anton is tired of listening how Danik describes every sparrow that eats grain from the barn. Anton doesn't know when the fairy tale ends, so he asked you to determine, by the end of which day the barn will become empty for the first time. Help Anton and write a program that will determine the number of that day!
Input
The only line of the input contains two integers n and m (1≤n,m≤1018)− the capacity of the barn and the number of grains that are brought every day.
Output
Output one integer− the number of the day when the barn will become empty for the first time. Days are numbered starting with one.
Examples
Input
5 2
Output
4
Input
8 1
Output
5
Note
In the first sample the capacity of the barn is five grains and two grains are brought every day. The following happens:
  • At the beginning of the first day grain is brought to the barn. It's full, so nothing happens.
  • At the end of the first day one sparrow comes and eats one grain, so 5-1=4 grains remain.
  • At the beginning of the second day two grains are brought. The barn becomes full and one grain doesn't fit to it.
  • At the end of the second day two sparrows come. 5-2=3 grains remain.
  • At the beginning of the third day two grains are brought. The barn becomes full again.
  • At the end of the third day three sparrows come and eat grain. 5-3=2 grains remain.
  • At the beginning of the fourth day grain is brought again. 2+2=4 grains remain.
  • At the end of the fourth day four sparrows come and eat grain. 4-4=0 grains remain. The barn is empty.
So the answer is 4, because by the end of the fourth day the barn becomes empty.

输入格式

输入的唯一一行包含两个整数nm——谷仓的容量和每天带来的谷物数量。

数据范围

1≤nm≤1018


输出格式

输出一个整数——谷仓第一次变空的日期时间从1开始算起。

输入样例 复制

5 2

输出样例 复制

4