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:

import java.io.*;
import java.util.*;
import java.text.*;

public class FollowTrafficRules
{
	public Scanner in = new Scanner(System.in);
	public PrintStream out = System.out;

	public double len, d, w, vmax, a;
	
	DecimalFormat fmt = new DecimalFormat("0.0000000000000000");
	
	public void main()
	{
		a = in.nextDouble();
		vmax = in.nextDouble();
		len = in.nextDouble();
		d = in.nextDouble();
		w = in.nextDouble();
		
		out.println(fmt.format(T()));
	}//end public void main()
	
	public double T()
	{
		double t, s;
		
		double t1, s1;
		t1 = vmax / a;
		s1 = vmax*vmax/(2.0*a);
		
		double t3, s3;
		t3 = w/a;
		s3 = w*w/(2.0*a);
				
		if(w >= vmax)
		{
			if(s1 < len)
			{
				return t1 + (len - s1)/vmax;
			}
			else
			{
				return Math.sqrt(2.0*len/a);
			}			
		}
		else
		{
			//w < vmax
			
			double t2, s2, v2;
			t2 = Math.sqrt(2.0*d/a);
			v2 = a*t2;
			
			double tx, vx;
			vx = Math.sqrt((2.0*a*d + w*w)/2.0);
			tx = vx / a;	
			
			//vmax > w

			//v2 > vx > w
			
			if(v2 < w)
			{
				if(v2 > vmax)
				{
					//v2 > vmax > w
					if(vmax > vx)
					{
						return tx + (vx - w)/a + T2(w);
					}
					else
					{
						double ty, sy;
						ty = (vmax - w)/a;
						sy = ty * (vmax + w)/2.0;
						return t1 + ty + (d - s1 - sy)/vmax + T2(w);
					}
				}
				else
				{
					//v2 < w, v2 <= vmax
					return t2 + T2(v2);					
				}
			}
			else if(v2 > vmax) //v2 >= w, vmax > w
			{
				//v2 > vmax > w
				if(vmax > vx)
				{
					return tx + (vx - w)/a + T2(w);
				}
				else
				{
					double ty, sy;
					ty = (vmax - w)/a;
					sy = ty * (vmax + w)/2.0;
					return t1 + ty + (d - s1 - sy)/vmax + T2(w);
				}
			}
			else  //vmax >= v2 >= w
			{
				//out.println("Questionable.");
				//return binary() + T2(w);
				
				//return  t3 + (d-s3)/w + T2(w);

				return tx + (vx - w)/a + T2(w);
			}
		}
	}
	
	public double binary()
	{
		double low, high, t, s;
		low = 0.0; high = vmax/a;
		
		for(int c=0;c<50;++c)
		{
			t = (low+high)/2;
			s = (a*t*t)/2 + ((a*t - w)/a)*(a*t + w)/2.0;
			
			if(s > d) high = t;
			else low = t;
		}
		t = (low+high)/2;
		return t + (a*t - w)/a;
	}
	
/*
	public double T()
	{
		double t1, s1, tx, sx, vx, ty, vy, sz, tz;
		t1 = vmax / a;
		s1 = a*t1*t1 / 2.0;
		
		vx = Math.sqrt((2.0*a*d + w*w)/2.0);
		tx = vx / a;
		
		if(s1 < d)
		{
			//reaches vmax
			if(vx < vmax)
			{
				//stops at vx
				return tx + (vx - w)/a + T2(w);
			}
			else //vx >= vmax
			{
				//stops at vmax
				if(w > vmax)
				{
					return t1 + (d - s1)/vmax + T2(vmax);
				}
				else
				{
					tz = (vmax - w)/a;
					sz = ((vmax + w)/2.0) * tz;
					
					return t1 + (d-sz-s1)/vmax + tz + T2(w);					
				}
			}
		}
		else //s1 >= d
		{
			//never reaches vmax
			vy = Math.sqrt(2.0*d*a);
			ty = vy / a;
			if(vx < vy)
			{
				//stops at vx
				return tx + (vx - w)/a + T2(w);
			}
			else //vx >= vy
			{
				if(w < vy)
				{
					return w/a + (d - w*w/(2.0*a))/w + T2(w);
				}
				else //w >= vy
				{
					//goes to vy, accelerate all the way
					return ty + T2(vy);		
				}
			}
		}
	}
*/	
	public double T2(double v0)
	{
		//v0 <= min(w, vmax)
		
		double t1, s1;
		t1 = (vmax - v0)/a;
		s1 = ((vmax + v0)/2.0)*t1;
		
		if(s1 < len-d)
		{
			//reaches vmax
			return t1 + (len-d-s1)/vmax;
		}
		else //s1 >= len - d
		{
			//does not reach vmax
			return (-v0 + Math.sqrt(v0*v0 + 2*a*(len-d)))/a;
		}
	}
	
	public static void main(String[] args)
	{
		(new FollowTrafficRules()).main();
	}
}