Time limit
1s
Memory limit
128 MB
Manhattan's roads lie on an integer coordinate grid.
Heewon wants to travel from one grid corner A(Ax, Ay) to another grid corner B(Bx, By). If only avenues and streets are used, the shortest distance between the two points is |Ax - Bx| + |Ay - By|.
During the trip, roads may be changed only at points where roads intersect. Considering every usable road, including Broadway, find the length of the shortest route from A to B.
The input first gives Ax Ay Bx By. Here A = (Ax, Ay) and B = (Bx, By).
Then three numbers P Q R are given for Broadway. Broadway's equation is Px + Qy = R.
Print the shortest distance from A to B. An absolute or relative error of at most 10^-9 is accepted.