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:

/**
 * Date: 17 Feb, 2018
 *
 * @author Prasad-Chaudhari
 * @email prasadc8897@gmail.com
 */
import java.util.Scanner;

public class NewProgram1 {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        double a = in.nextInt();
        double v = in.nextInt();
        double l = in.nextInt();
        double d = in.nextInt();
        double w = in.nextInt();
        double time = 0;
//        if(v<=w){
//            if((v*v)/(2*a)>l){
//                System.out.print(Math.sqrt(2*l/a));
//                System.exit(0);
//            }
//            else{
//                time = v/a;
//                double s = v*v/(2*a);
//                time+=(l-s)/v;
//                System.out.println(time);
//                System.exit(0);
//            }
//        }
//        if(2*a*d<w*w){
//            if((v*v-w*w)/2*a<(l-d)){
//                time = (v-w)/2;
//                double s = (v*v-w*w)/2*a;
//                time+= (l-d-s)/v;
//            }
//            else{
//                time = (-w+Math.sqrt(w*w+2*a*(l-d)))/a;
//            }
//            if(((v*v)/2*a)+((v*v-w*w)/2*a)<=d){
//                time += (v)/a + (v-w)/a;
//                double s = ((v*v)/2*a)+((v*v-w*w)/2*a);
//                time += (d-s)/v;
//            }
//            else{
//                double max = v;
//                double min = w;
//                double e = 0.00000001;
//                double dist = 0;
//                while(e>Math.abs(d-dist)){
//                    double mid = (min+max)/2;
//                    dist = ((mid*mid)/2*a)+((mid*mid-w*w)/2*a);
//                    if(dist>d){
//                        max = mid;
//                    }
//                    else{
//                        min = mid;
//                    }
//                }
//                double req = (max+min)/2;
//                time += (req)/a+(req-w)/a;
//            }
//        }
//        else{
//            if(v*v>2*a*l){
//                time = Math.sqrt(2*l/a);
//            }
//            else{
//                time = (v)/a;
//                double s = (v*v)/(2*a);
//                time+=(l-s)/v;
//            }
//        }
        if (v <= w) {
            if ((v * v) > 2*l*a) {
                time = Math.sqrt(2 * l / a);
//                System.out.println("1");
            } else {
                time = v / a;
                double s = v * v / (2 * a);
                time += (l - s) / v;
//                System.out.println("2");
            }
        } else {
            if (2 * a * d <= w*w) {
                if(v*v>=2*a*l){
                    time = Math.sqrt(2*l/a);
//                    System.out.println("3");
                }
                else{
                    time = v/a;
                    double s = (v*v)/(2*a);
                    time += (l-s)/v;
//                    System.out.println("4");
                }
            }
            else{
                if(v*v-w*w>2*a*(l-d)){
                    double min = w;
                    double max = v;
                    double mid = (max+min)/2;
                    double s = 0;
                    while(Math.abs(s-(l-d))>.00000001){
                        s = (mid*mid-w*w)/(2*a);
                        if(s>(l-d)){
                            max = mid;
                        }
                        else{
                            min = mid;
                        }
                        mid= (max+min)/2;
                    }
                    time += (mid-w)/a;
//                    System.out.println("5");
                }
                else{
                    time = (v-w)/a;
                    double s = (v*v-w*w)/(2*a);
                    time+= (l-d-s)/v;
//                    System.out.println("6");
                }
                if(a*d+(w*w)/2<=v*v){
                    double max = v ;
                    double min = w;
                    double mid = (v+w)/2;
                    double s=0;
                    while(Math.abs(s-d)>.000000001){
                        s = (mid*mid/(2*a))+(mid*mid-w*w)/(2*a);
                        if(s>d){
                            max = mid;
                        }
                        else{
                            min = mid;
                        }
                        mid = (max+min)/2;
                    }
                    time+=(2*mid-w)/a;
//                    System.out.println("7");
                }
                else{
                    time += v/a;
                    time += (v-w)/a;
                    double s = d - (v*v)/(2*a) - (v*v-w*w)/(2*a);
                    time+= s/v;
//                    System.out.println("8");
                }
            }
        }
        System.out.println(time);
    }
}
//200 1000 3 2 1