Time limit: 1.0s
Memory limit: 256M
Farmer Bob is buying cereal boxes at his local grocery store, which are priced in the following way:
- The first cereal boxes cost dollars each
- For every boxes purchased, the price of any subsequent boxes is increased by dollars
Bob only has dollars to spend. What is the maximum number of cereal boxes he can buy?
For all subtasks:
The only line of input contains four integers , , and .
Output the maximum number of cereal boxes Bob can buy.
Sample Input 1
2 1 3 35
Sample Output 1
Explanation for Sample 1
The prices of the cereal boxes Bob can buy are , , , , , and dollars respectively.
Sample Input 2
1 15 1 10
Sample Output 2