Problem2443--ABC270B - Hammer

2443: ABC270B - Hammer

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

高桥站在数轴的原点。他想前往坐标x。

坐标y处有一面墙,高桥一开始无法越过。

然而,在坐标z处拿起锤子后,他可以摧毁墙壁并通过。

确定高桥是否能够实现目标。如果可以的话,输出他需要走过的最小总距离,如果不能达成目标,输出-1

Problem Statement

Takahashi is at the origin of a number line. He wants to reach a goal at coordinate XX.
There is a wall at coordinate YY, which Takahashi cannot go beyond at first.
However, after picking up a hammer at coordinate ZZ, he can destroy that wall and pass through.
Determine whether Takahashi can reach the goal. If he can, find the minimum total distance he needs to travel to do so.

Constraints

  • -1000 \leq X,Y,Z \leq 10001000X,Y,Z1000
  • XXYY, and ZZ are distinct, and none of them is 00.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:
XXYYZZ

Output

If Takahashi can reach the goal, print the minimum total distance he needs to travel to do so. If he cannot, print -1 instead.

Sample Input Copy

20 10 -10

Sample Output Copy

40

Source/Category