Under construction

Still being built. Things may change

Elevator

Interview

Time limit1sMemory limit256 MB

Summary
An elevator with buttons that move up U or down D floors, staying within floors 1 to F, needs the minimum presses to go from floor S to floor G.
Level

Medium4 of 10

Topics
BFS, Graph, Shortest path, Implementation
Solved
No attempts yet

Problem

Kangho applied to a coding-education startup, and today is his interview day. But he overslept and arrived late at the building where the company is located.

The company occupies a tall building with FF floors in total, and its office is on floor GG. Kangho is currently on floor SS and wants to take the elevator to floor GG.

A normal elevator has a button for every floor, but the elevator Kangho boarded has only two buttons.

  • Button U: go up by UU floors.
  • Button D: go down by DD floors.

If going up by UU floors would rise above the top floor (FF), or going down by DD floors would drop below floor 11, the elevator does not move.

Find the minimum number of button presses Kangho needs to reach floor GG. If he cannot reach floor GG using only the elevator, print use the stairs.

Input

The first line contains five integers FF, SS, GG, UU, and DD, separated by spaces. (1≤S,G≤F≤1061 \le S, G \le F \le 10^6, 0≤U,D≤1060 \le U, D \le 10^6)

The building starts at floor 11, and the highest floor is FF.

Output

Print the minimum number of button presses needed to go from floor SS to floor GG. If the elevator cannot reach floor GG, print use the stairs.

Examples2

  1. Example 1

    Input
    10 1 10 2 1
    
    Expected output
    6
    
  2. Example 2

    Input
    100 2 1 1 0
    
    Expected output
    use the stairs