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.*;
import java.util.*;

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

	public Pair C, H, S;
	public double T1, T2, M1, M2;
	
	public void main()
	{
		T1 = in.nextDouble();
		T2 = in.nextDouble();
		
		C = new Pair(in.nextDouble(), in.nextDouble());
		H = new Pair(in.nextDouble(), in.nextDouble());;
		S = new Pair(in.nextDouble(), in.nextDouble());
		
		M1 = T1 + C.dist(S) + S.dist(H);
		M2 = T2 + C.dist(H);
		
		double x, low, high;
		
		low = 0.0; high = Math.min(M1, M2);
		
		//max x : poss(x)
		for(int TC=0;TC<100;++TC)
		{
			x = (low+high)/2.0;
			
			if(poss(x)) low = x;
			else high = x;
		}
		
		x = (low + high)/2.0;
		
		if(C.dist(S) + S.dist(H) <= M2 + tol)
		{
			x = Math.min(M1, M2);
		}
		
		out.println(x);
	}//end public void main()

	public boolean poss(double x)
	{
		double R1, R2;
		R1 = M1 - x - S.dist(H);
		R2 = M2 - x;
		
		if(R1 < -tol || R2 < -tol) return false;
		//R1 = Math.max(R1, 0.0);
		//R2 = Math.max(R2, 0.0);
		
		Circle[] cir = new Circle[3];
		
		cir[0] = new Circle(C.x, C.y, x);
		cir[1] = new Circle(S.x, S.y, R1);
		cir[2] = new Circle(H.x, H.y, R2);
		
		return overlap(cir);
	}

//-------------------------- Circle -------------------------------------------------
	//Uses class Pair, method eq, double tol
	private class Circle
	{
		public Pair c;
		public double r;
		
		public Circle(double xx, double yy, double rr) { c = new Pair(xx, yy); r = rr; }
		public Circle(Pair cc, double rr) { c = cc; r = rr; }
		
		//return intersection points with respect to circumference
		public Pair[] intersection(Circle u)
		{
			if(r < u.r) return u.intersection(this);
			
			//r >= u.r
			if(equals(u)) return null;
			if(!overlap(u)) return new Pair[0];
			
			double D = c.dist(u.c);
			Pair v = u.c.subtract(c).multiply(r/D);
			
			//Touches from outside
			if(eq(D, r + u.r))
			{
				return new Pair[]{ c.add(v) };
			}
			
			if(contains(u))
			{
				//Touches from inside, r >= u.r
				if(eq(D + u.r, r))
				{
					return new Pair[]{ c.add(v) };
				}
				return new Pair[0];
			}
			
			//Intersects at two points, r >= u.r
			double a = Math.acos((r*r + D*D - u.r*u.r)/(2.0*r*D));
			
			return new Pair[]{c.add(v.rotate(a)), c.add(v.rotate(-a))};
		}
		
		public boolean overlap(Circle u)
		{
			return c.dist(u.c) <= r + u.r + tol; 
		}
		
		public boolean contains(Circle u)
		{
			return c.dist(u.c) + u.r <= r + tol;
		}
		
		public boolean contains(Pair p)
		{
			return p.dist(c) <= r + tol;
		}
		
		public boolean equals(Circle u)
		{
			return c.compareTo(u.c) == 0 && eq(r, u.r);
		}
	}
//-------------------------- End Circle ---------------------------------------------
	
	//return if there is a common point for all circles with respect to area
	//uses class Circle, class Pair
	public boolean overlap(Circle[] v)
	{
		if(v == null) return false;
		if(v.length == 0) return true;
		
		boolean[] use = new boolean[v.length];
		Arrays.fill(use, true);
		
		int i, j;
		//make distinct
		for(i=0;i<v.length;++i) if(use[i])
		{
			for(j=i+1;j<v.length;++j) if(use[j] && v[i].equals(v[j])) 
				use[j] = false;
		}
		
		//remove bigger circles which contain another smaller circle
		for(i=0;i<v.length;++i) if(use[i])
		{
			for(j=0;j<v.length;++j) if(i!=j && use[j] && v[i].contains(v[j]))
			{
				use[i] = false;
				break;
			}
		}
		
		//collect subset of circles that survived
		ArrayList<Circle> A = new ArrayList<Circle>();
		for(i=0;i<v.length;++i) if(use[i]) A.add(v[i]);
		v = A.toArray(new Circle[0]);
		
		if(v.length == 1) return true;
		
		TreeSet<Pair> S = new TreeSet<Pair>();
		for(i=0;i<v.length;++i)
		{
			for(j=i+1;j<v.length;++j)
			{
				Pair[] ret = v[i].intersection(v[j]);
				for(Pair T : ret) S.add(T);
			}
		}
		
		boolean OK;
		for(Pair T : S)
		{
			OK = true;
			for(i=0;i<v.length;++i) if(!v[i].contains(T))
			{
				OK = false;
				break;
			}
			
			if(OK) return true;
		}
		
		return false;
	}//end public boolean overlap(Circle[] v)
	
	//double point
	//Use eq(double, double)
	private class Pair implements Comparable<Pair>
	{
		public double x, y;
		public Pair(double xx, double yy) { x = xx; y = yy; }
		
		public int compareTo(Pair u)
		{
			if(!eq(x, u.x)) return (x < u.x ? -1 : 1);
			if(!eq(y, u.y)) return (y < u.y ? -1 : 1);
			return 0;
		}

		public Pair midpoint(Pair u) { return new Pair((x + u.x)/2, (y + u.y)/2); }
		public Pair add(Pair u) { return new Pair(x + u.x, y + u.y); }
		public Pair subtract(Pair u) { return new Pair(x - u.x, y - u.y); }
		public Pair multiply(double s) { return new Pair(x*s, y*s); }

		public double length() { return Math.sqrt(x*x + y*y); }
		public double dist(Pair u) { return subtract(u).length(); }

		public Pair rotate(double t) 
		{
			double xx, yy;
			xx = x*Math.cos(t) - y*Math.sin(t);
			yy = x*Math.sin(t) + y*Math.cos(t);
			return new Pair(xx, yy); 
		}

		public double[] ret() { return new double[]{x, y}; }
		public String toString() { return "("+x+","+y+")"; }
	}
	
	public double tol = 1e-12;
	public boolean eq(double x, double y) { return Math.abs(x - y) < tol; }
	
	
	public static void main(String[] args)
	{
		(new TwoFriends()).main();
	}
}