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.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.text.MessageFormat;
import java.util.StringTokenizer;

/**
 * http://codeforces.com/problemset/problem/5/D
 *
 */
public class FollowTrafficRules {

	/**
	 * determines if it is used as an online submission or test.
	 */
	final static boolean ONLINE_SUBMISSION = System.getProperty("ONLINE_JUDGE") != null;

	static class Run implements Runnable {

		/**
		 * determines if output should be written to a file or to console when testing locally.
		 */
		final static boolean OUTPUT_TO_FILE = false;

		// Idea:.
		@Override
		public void run() {

			double a = nextDouble(), v = nextDouble(), l = nextDouble(), d = nextDouble(), w = nextDouble();

			double time = 0;
			if (v > w) { // car is faster than the limit
				double dToLimit = accelerateToV(0, w, a); // distance to reach limit
				double dToMaxFromLimit = accelerateToV(w, v, a); // distance to reach max from limit pace
				if (d - dToLimit > 0) { // limit is reached before the sign -> keep accelarating
					time += timeElapsed(0, w, dToLimit, a); // time to reach limit
					if (2 * dToMaxFromLimit > d - dToLimit) { // can't reach max speed and decelarate to w before sign
						time += 2 * timeElapsed(w, v, (d - dToLimit) / 2, a); // time to accelarate and decelarate
					} else {
						// time to accelarate and run at max plus time to decelerate.
						time += timeElapsed(w, v, d - dToLimit - dToMaxFromLimit, a) + timeElapsed(w, v, dToMaxFromLimit, a);
					}
					time += timeElapsed(w, v, l - d, a); // time between the sign and Berland.
				} else { // limit speed isn't reached before the sign
					time += timeElapsed(0, v, l, a);
				}
			} else {
				time += timeElapsed(0, v, l, a); // time if max speed is lower than max speed
			}

			printf("%f", time);
		}

		/**
		 * @param v0
		 *            start speed
		 * @param vMax
		 *            max speed
		 * @param d
		 *            distance
		 * @param a
		 *            acceleration
		 * @return time
		 */
		double timeElapsed(double v0, double vMax, double d, double a) {
			double ans;
			double tCrit = (vMax - v0) / a;
			double dCrit = tCrit / 2 * (vMax + v0);
			if (d <= dCrit) {
				ans = (-v0 + Math.sqrt(v0 * v0 + 2 * a * d)) / a;
			} else {
				ans = d / vMax - tCrit / (2 * vMax) * (v0 - vMax);
			}
			return ans;
		}

		/**
		 * returns the distance needed.
		 */
		double accelerateToV(double v0, double v, double a) {
			double t = (v - v0) / a;
			return v0 * t + a / 2 * t * t;
		}

		// ==============================================================
		// ======== Everything below is used across all problems ========
		// ==============================================================
		final String className = getClass().getEnclosingClass().getSimpleName();
		final String inputFilename = "io/input-" + className + ".txt";
		final String outputFilename = "io/output-" + className + ".txt";
		BufferedReader in;
		PrintWriter out;
		StringTokenizer strTok;

		Run() {
			if (ONLINE_SUBMISSION) {
				initConsoleIO();
			} else {
				initFileIO();
			}
		}

		/**
		 * read input from console and write output to console.
		 */
		void initConsoleIO() {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
		}

		/**
		 * read input from {@value #inputFilename} and write output to console or to {@value #outputFilename} depending on {@link #OUTPUT_TO_FILE}.
		 */
		void initFileIO() {
			try {
				in = new BufferedReader(new FileReader(inputFilename));
				if (OUTPUT_TO_FILE) {
					out = new PrintWriter(new FileWriter(outputFilename));
				} else {
					out = new PrintWriter(new OutputStreamWriter(System.out));
				}
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		/**
		 * Close BufferedReader and PrintWriter.
		 */
		void close() {
			try {
				in.close();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		float nextFloat() {
			return Float.parseFloat(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		String nextLine() {
			try {
				return in.readLine();
			} catch (IOException e) {
				return "__NULL";
			}
		}

		public int[] nextArr(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; ++i) {
				a[i] = nextInt();
			}
			return a;
		}

		String nextToken() {
			while (strTok == null || !strTok.hasMoreTokens()) {
				String line;
				try {
					line = in.readLine();
					strTok = new StringTokenizer(line);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

			return strTok.nextToken();
		}

		/**
		 * output to console.
		 */
		void cout(Object o) {
			System.out.println(o);
		}

		/**
		 * writes to PrintWriter. See {@link java.io.PrintWriter#write(String) PrintWriter.write} for more details.
		 */
		void print(Object o) {
			out.write(o.toString());
		}

		/**
		 * writes to PrintWriter and add new line. See {@link java.io.PrintWriter#write(String) PrintWriter.write} for more details.
		 */
		void println(Object o) {
			out.write(o.toString() + '\n');
		}

		/**
		 * See documentation {@link java.io.PrintWriter#printf(String, Object) here}.
		 */
		void printf(String format, Object... args) {
			out.printf(format, args);
		}

		/**
		 * See documentation {@link java.text.MessageFormat#format(String, Object) here}.
		 */
		String sprintf(String format, Object... args) {
			return MessageFormat.format(format, args);
		}

		/**
		 * Print array with a seperator between elements.
		 */
		void printArray(int[] array, String seperator) {
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < array.length; i++) {
				if (i > 0) {
					sb.append(" ");
				}
				sb.append(array[i]);
			}
			println(sb.toString());
		}
	}

	public static void main(String[] args) throws IOException {
		Run run = new Run();
		Thread thread = new Thread(run);
		if (!ONLINE_SUBMISSION) {
			long start = System.currentTimeMillis();
			thread.run();
			System.out.println("Time elapsed: " + ((System.currentTimeMillis() - start) / 1000.0) + " sec\n");
		} else {
			thread.run();
		}
		run.close();
	}
}