Ritisha's Way Home
It is 2:00 AM, and Ritisha is ready to leave the Duck Lounge and head home. Fortunately, the city is arranged as a grid, and a rideshare car is waiting for her.
The Duck Lounge is at the intersection , and Ritisha's home is at
. During each minute, the car can move at most
blocks horizontally and at most
blocks vertically. These movements happen at the same time.
More precisely, in one minute the car may change its -coordinate by any integer between
and
, and its
-coordinate by any integer between
and
. The car must remain at intersections with integer coordinates. There are no obstacles or one-way streets.
Find the minimum number of minutes Ritisha needs to reach home.
Input
The first line contains four integers ,
,
, and
(
): the coordinates of the Duck Lounge and Ritisha's home.
The second line contains two integers and
(
): the maximum horizontal and vertical distances the car can travel in one minute.
Output
Output a single integer: the minimum number of minutes Ritisha needs to reach home.
Examples
Input 1
11 8 2 3
4 2
Output 1
3
The car must travel blocks horizontally and
blocks vertically. It can travel
blocks horizontally per minute, and
vertically per minute. After
minutes, it can reach Ritisha's home.
Input 2
-5 12 8 -2
6 4
Output 2
4
Comments