Problem: Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was placed just one traffic sign, limiting the maximum speed. Traffic signs in Berland are a bit peculiar, because they limit the speed only at that point on the road where they are placed. Right after passing the sign it is allowed to drive at any speed.

It is known that the car of an average Berland citizen has the acceleration (deceleration) speed of a km/h2, and has maximum speed of v km/h. The road has the length of l km, and the speed sign, limiting the speed to w km/h, is placed d km (1 ≤ d < l) away from the capital of Berland. The car has a zero speed at the beginning of the journey. Find the minimum time that an average Berland citizen will need to get from the capital to Bercouver, if he drives at the optimal speed.

The car can enter Bercouver at any speed.

Input

The first line of the input file contains two integer numbers a and v (1 ≤ a, v ≤ 10000). The second line contains three integer numbers l, d and w (2 ≤ l ≤ 10000; 1 ≤ d < l; 1 ≤ w ≤ 10000).

Output

Print the answer with at least five digits after the decimal point.

Examples

Input

1 1
2 1 3


Output

2.500000000000


Input

5 70
200 170 40


Output

8.965874696353

Solution (in JAVA):

Solution:
//package src;

import java.util.Scanner;

public class T5D {

    public static void main(String[] args) {
        start(false);
    }

    public static void start(boolean isTest) {
        if (!isTest) {
            Scanner in = new Scanner(System.in);

            int a = in.nextInt();
            int v = in.nextInt();

            int distance = in.nextInt();
            int distanceToRoadSign = in.nextInt();
            int w = in.nextInt();

            double time = calculateTime(a, v, distanceToRoadSign, distance, w);
            System.out.println(time);
        } else {
            test();
        }
    }

    private static void test() {
        System.out.println(distanceFullAcceleration(5, 0, 40));
    }

    public static double calculateTime(int acceleration, int maxSpeed, int distanceToRoadSign, int distance, int limitingSpeed) {
        if (maxSpeed <= limitingSpeed) {
            return timeKnowingDistance(acceleration, 0, maxSpeed, distance);
        } //если максимальная скорость меньше ограничивающей

        //не успели набрать скорость превышающую на знаке
        double distanceToLimitingSpeed = distanceFullAcceleration(acceleration, 0, limitingSpeed);
        if (distanceToLimitingSpeed > distanceToRoadSign) {
            return timeKnowingDistance(acceleration, 0, maxSpeed, distance);
        }

        //считаем время, затраченное на преодолдение знака
        double timeToRoadSign = timeToRoadSign(acceleration, maxSpeed, distanceToRoadSign, distance, limitingSpeed);
        double timeToFinish = timeKnowingDistance(acceleration, limitingSpeed, maxSpeed, distance - distanceToRoadSign);
        return timeToRoadSign + timeToFinish;
    }

    public static double timeToRoadSign(int acceleration, int maxSpeed, int distanceToRoadSign, int distance, int limitingSpeed) {
        double distanceToMaxSpeed = distanceFullAcceleration(acceleration, 0, maxSpeed); //дистанция до полной скорости
        double distanceFromMaxSpeedToLimitingSpeed = distanceFullAcceleration(acceleration, limitingSpeed, maxSpeed); //дистанция торможения до ограничивающей скорости

        if (distanceToMaxSpeed + distanceFromMaxSpeedToLimitingSpeed < distanceToRoadSign) {
            //то есть ускоряемся до максимальной скорости, едем с максимальной скоростью, а затем тормозим до ограничивающей
            double t1 = timeFullAcceleration(acceleration, 0, maxSpeed);
            double t2 = timeConstantSpeedDistance(maxSpeed, distanceToRoadSign - distanceToMaxSpeed - distanceFromMaxSpeedToLimitingSpeed);
            double t3 = timeFullAcceleration(acceleration, limitingSpeed, maxSpeed);
            return t1 + t2 + t3;
        } else {
            // ускоряемся до некой Vx (которая в любом случае больше limitingSpeed)
            double Vx = calculateMaxSpeed(acceleration, 0, limitingSpeed, distanceToRoadSign);

            double t1 = timeFullAcceleration(acceleration, 0, Vx);
            double t2 = timeFullAcceleration(acceleration, limitingSpeed, Vx);
            return t1 + t2;
        }
    }

    public static double timeConstantSpeedDistance(double speed, double distance) {
        return distance / speed;
    }

    public static double timeFullAcceleration(int a, double v0, double v1) {
        return (v1 - v0) / a;
    } //время за которое скорость изменится с v0 до v1

    public static double distanceFullAcceleration(int a, double v0, double v1) {
        // s = (v^2 - v0^2) / +-2*a
        return (Math.pow(v1, 2) - Math.pow(v0, 2)) / (2 * a);
    } //расстояние которое будет преодолено, за время ускорения ("пока скорость меняется до v1") (требуется, что v1 > v0)

    public static double timeKnowingDistance(int a, double v0, double v1, int maxDistance) {
        double distance = distanceFullAcceleration(a, v0, v1); //преодоленное расстояние до макс скорости
        if (distance < maxDistance) {
            //дорога достаточно длинная, чтоб ускориться и ещё проехаться с максимальной скоростью
            double t1 = timeFullAcceleration(a, v0, v1);
            double t2 = timeConstantSpeedDistance(v1, maxDistance - distance);
            return t1 + t2;
        } else {
            // дорога слишком короткая, ускоримся до некоторой скорости Vx и gg
            // Vx^2 = 2 * distance * a + V0^2
            double t1 = timeFullAcceleration(a, v0, Math.sqrt(2 * maxDistance * a + Math.pow(v0, 2)));
            return t1;
        }
    } //время, потраченное на преодоление известной дистанции, учитывая что в начале просиходит ускорение

    public static double calculateMaxSpeed(int a, double vStart, double vEnd, int distance) {
        //2Vx^2 = 2 * a * d + V0^2 + Vend^2

        double rightPart = 2 * a * distance + vStart * vStart + vEnd * vEnd;
        double halfRightPart = rightPart / 2;
        return Math.sqrt(halfRightPart);
    } //очень подозрительно, похоже на error!
}