EasyRating 900
Two Rival Students
n students stand in a row; two rivals are at positions a and b. You may swap neighbours at most x times. Print the largest possible distance between the rivals.
Input
Four integers n, x, a, b.
Output
The largest distance.
Sample 1
Input
5 1 3 2
Output
2
Sample 2
Input
100 33 100 1
Output
99
Output appears here