547. Anton and the Fairy Tale

0

Medium

Anton enjoys listening to fairy tales, especially when his best friend Danik tells them. Currently, Danik is telling Anton a fairy tale about an emperor who was very wealthy and had a large amount of grain. The emperor decided to build a massive barn to store all of his grain. Skilled builders worked on the barn for three days and three nights, but they accidentally left a small hole through which sparrows could enter and steal grain.
In the fairy tale, the following events occur: On the first day, the barn is filled with n grains. Each day thereafter, the following happens:
- m grains are added to the barn. If the barn becomes full, any excess grains are returned (for the purposes of this problem, we can ignore the excess grains).
- Sparrows arrive and eat the grain. On the i-th day, i sparrows arrive (e.g., one sparrow on the first day, two sparrows on the second day, and so on). Each sparrow consumes one grain. If the barn is empty, the sparrows eat nothing.
Anton is tired of hearing about each sparrow that eats grain from the barn. He doesn't know when the fairy tale will end, so he needs your help to determine the day on which the barn will become empty for the first time. Write a program to calculate the number of that day!

Input Format

The input consists of a single line containing two integers n and m, representing the capacity of the barn and the number of grains added each day, respectively.

Output Format

Print a single integer, the number of the day on which the barn will become empty for the first time. Days are numbered starting from one.

Example

Input

5 2

Output

4

Constraints

1 <= n , m<= 10^18

Loading...

View Submissions

Console