A higher resolution is required to access the IDE
- 209
Statement
Goal
A building has n floors.It has an elevator that is controlled by two buttons only:
By pressing the
By pressing the
If the elevator is commanded to go lower than the first floor or higher than the n-th floor, it will refuse to move and remain on its current floor.
The elevator starts on the k-th floor. Count how many times the buttons should be pressed to move the elevator to the m-th floor.
Input
Line 1: 5 space separated integers in order: n a b k m
Output
One line that contains 1 integer - minimal number of buttons pressed, required to move the elevator to the floor m.
If it is impossible to move the elevator to the floor m, printIMPOSSIBLE
If it is impossible to move the elevator to the floor m, print
Constraints
1 ≤ n ≤ 10000
1 ≤ a ≤ n
1 ≤ b ≤ n
1 ≤ k ≤ n
1 ≤ m ≤ n
1 ≤ a ≤ n
1 ≤ b ≤ n
1 ≤ k ≤ n
1 ≤ m ≤ n
Example
Input
10 1 1 8 5
Output
3
A higher resolution is required to access the IDE