Problem: Two neighbours, Alan and Bob, live in the city, where there are three buildings only: a cinema, a shop and the house, where they live. The rest is a big asphalt square. 

Once they went to the cinema, and the film impressed them so deeply, that when they left the cinema, they did not want to stop discussing it.

Bob wants to get home, but Alan has to go to the shop first, and only then go home. So, they agreed to cover some distance together discussing the film (their common path might pass through the shop, or they might walk circles around the cinema together), and then to part each other's company and go each his own way. After they part, they will start thinking about their daily pursuits; and even if they meet again, they won't be able to go on with the discussion. Thus, Bob's path will be a continuous curve, having the cinema and the house as its ends. Alan's path — a continuous curve, going through the shop, and having the cinema and the house as its ends.

The film ended late, that's why the whole distance covered by Alan should not differ from the shortest one by more than t1, and the distance covered by Bob should not differ from the shortest one by more than t2.

Find the maximum distance that Alan and Bob will cover together, discussing the film.

Input

The first line contains two integers: t1, t2 (0 ≤ t1, t2 ≤ 100). The second line contains the cinema's coordinates, the third one — the house's, and the last line — the shop's. 

All the coordinates are given in meters, are integer, and do not exceed 100 in absolute magnitude. No two given places are in the same building.

Output

In the only line output one number — the maximum distance that Alan and Bob will cover together, discussing the film. Output the answer accurate to not less than 4 decimal places.

Examples

Input

0 2
0 0
4 0
-3 0


Output

1.0000000000


Input

0 0
0 0
2 0
1 0


Output

2.0000000000

Solution (in JAVA):

Solution:

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws FileNotFoundException, IOException {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();

	}
}

class Circles {
	Pair point;
	double second;

	Circles(Pair point, double second) {
		this.point = point;
		this.second = second;
	}
}

class Pair {
	double first;
	double second;

	Pair(double first, double second) {
		this.first = first;
		this.second = second;
	}

}

// pair problem can be done using stack
class TaskB {
	int MAXN = (int) 1e9 + 7;
	double t1;
	double t2;
	double eps = 1e-10;
	double d[];

	void solve(int testNumber, InputReader in, PrintWriter pw) {
		double t1 = in.nextDouble();
		double t2 = in.nextDouble();
		double[] x = new double[3];
		double[] y = new double[3];
		for (int i = 0; i < 3; ++i) {
			x[i] = in.nextDouble();
			y[i] = in.nextDouble();
		}
		double[] d = new double[3];
		for (int i = 0; i < 3; ++i) {
			int a = (i + 1) % 3;
			int b = (i + 2) % 3;
			d[i] = Math.sqrt((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));
		}
		if (d[1] + d[0] <= d[2] + t2) {
			pw.printf("%.10f\n", Math.min(d[2] + t2, d[0] + d[1] + t1));
		} else {
			double deltaAlpha = Math.abs(Math.atan2(y[1] - y[0], x[1] - x[0]) - Math.atan2(y[2] - y[0], x[2] - x[0]));
			if (deltaAlpha > Math.PI) {
				deltaAlpha = 2 * Math.PI - deltaAlpha;
			}
			double l = 0;
			double r = Math.min(d[2] + t2 / 2, d[1] + t1 / 2);
			for (int step = 0; step < 100; ++step) {
				double m = (l + r) / 2;
				double freedom0 = d[2] + t2 - m;
				boolean enough = true;
				double alpha = (m * m + d[2] * d[2] - freedom0 * freedom0) / (2 * m * d[2]);
				if (alpha < -1)
					alpha = -1;
				if (alpha > 1)
					alpha = 1;
				alpha = Math.acos(alpha);
				double freedom1 = d[1] + t1 - m;
				double beta = (m * m + d[1] * d[1] - freedom1 * freedom1) / (2 * m * d[1]);
				if (beta < -1)
					beta = -1;
				if (beta > 1)
					beta = 1;
				beta = Math.acos(beta);
				if (alpha + beta < deltaAlpha)
					enough = false;
				if (enough)
					l = m;
				else
					r = m;
			}
			double leeway = Math.min(d[1] + t1 - d[2] - d[0], t2);
			if (leeway > 1e-9) {
				l = Math.max(l, leeway + d[2]);
			}
			double u = (d[2] + t2 - d[1] - t1 + d[0]) / 2;
			if (u > 0 && u < d[0]) {
				double aa = Math.atan2(y[2] - y[1], x[2] - x[1]);
				double xx = x[1] + Math.cos(aa) * u;
				double yy = y[1] + Math.sin(aa) * u;
				double dx = xx - x[0];
				double dy = yy - y[0];
				leeway = d[2] + t2 - u - Math.sqrt(dx * dx + dy * dy);
				if (leeway > 1e-9)
					l = Math.max(l, d[2] + t2 - u);
			}
			pw.printf("%.10f", l);
		}
	}

	long pow(int n, int m) {
		if (m == 0)
			return 1;
		long ans = pow(n, m / 2);
		ans = (ans * ans);
		if (m % 2 == 1) {
			ans = (ans * n);
		}
		return ans;
	}

	double pow(double n, int m) {
		if (m == 0)
			return 1;
		double ans = pow(n, m / 2);
		ans = (ans * ans);
		if (m % 2 == 1) {
			ans = (ans * n);
		}
		return ans;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}