CF746C Tram
Description
The tram in Berland goes along a straight line from the point $ 0 $ to the point $ s $ and back, passing $ 1 $ meter per $ t_{1} $ seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points $ x=0 $ and $ x=s $ .
Igor is at the point $ x_{1} $ . He should reach the point $ x_{2} $ . Igor passes $ 1 $ meter per $ t_{2} $ seconds.
Your task is to determine the minimum time Igor needs to get from the point $ x_{1} $ to the point $ x_{2} $ , if it is known where the tram is and in what direction it goes at the moment Igor comes to the point $ x_{1} $ .
Igor can enter the tram unlimited number of times at any moment when his and the tram's positions coincide. It is not obligatory that points in which Igor enter and exit the tram are integers. Assume that any boarding and unboarding happens instantly. Igor can move arbitrary along the line (but not faster than $ 1 $ meter per $ t_{2} $ seconds). He can also stand at some point for some time.
Input Format
The first line contains three integers $ s $ , $ x_{1} $ and $ x_{2} $ ( $ 2
Output Format
Print the minimum time in seconds which Igor needs to get from the point $ x_{1} $ to the point $ x_{2} $ .
Explanation/Hint
In the first example it is profitable for Igor to go by foot and not to wait the tram. Thus, he has to pass $ 2 $ meters and it takes $ 8 $ seconds in total, because he passes $ 1 $ meter per $ 4 $ seconds.
In the second example Igor can, for example, go towards the point $ x_{2} $ and get to the point $ 1 $ in $ 6 $ seconds (because he has to pass $ 3 $ meters, but he passes $ 1 $ meters per $ 2 $ seconds). At that moment the tram will be at the point $ 1 $ , so Igor can enter the tram and pass $ 1 $ meter in $ 1 $ second. Thus, Igor will reach the point $ x_{2} $ in $ 7 $ seconds in total.