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 PYTHON):

Solution:
from math import sqrt, acos, sin, cos, asin, pi

PREC = 0.00005
def floatEq(x, y): return abs(x-y) < PREC
I=lambda: map(int, raw_input().split())
D=lambda x1, y1, x2, y2: sqrt((x1-x2)**2+(y1-y2)**2)

t2, t1 = I()
x0, y0 = I()
x1, y1 = I()
x2, y2 = I()

d01 = D(x0, y0, x1, y1)
d02 = D(x0, y0, x2, y2)
d12 = D(x1, y1, x2, y2)

if t1 == 0 and t2 == 0:
	if floatEq(d02 + d12, d01) or floatEq(d01 + d12, d02):
		res = d01
	else:
		res = 0.0
elif t2 == 0:
	a = d02+d12
	b = d01+t1
	if a < b or floatEq(a, b):
		res = a
	elif floatEq(d02 + d01, d12):
		res = min(d02, t1/2.0)
	elif floatEq(d01 + d12, d02):
		res = d01 + min(d02, t1/2.0)	
	else:
		cosAlph = (d01**2 + d02**2 - d12**2)/(2*d01*d02)
		res = (d01**2 - b**2)/(2*d01*cosAlph - 2*b)
elif t1 == 0:
	a = d01+d12
	b = d02+t2
	if a < b or floatEq(a, b) or floatEq(d02 + d12, d01):
		res = d01
	elif floatEq(d02 + d01, d12):
		res = min(d01, t2/2.0)
	elif floatEq(d02 + d12, d01):
		res = d02 + min(d01, t2/2.0)
	else:
		cosAlph = (d01**2 + d02**2 - d12**2)/(2*d01*d02)
		res = (d02**2 - b**2)/(2*d02*cosAlph - 2*b)
else:
	a2 = d02+d12
	b2 = d01+t1
	a1 = d01+d12
	b1 = d02+t2
	if a2 < b2 or floatEq(a2, b2):
		res = min(b2-a2, t2) + d12 + d02
		# print('-')
	elif a1 < b1 or floatEq(a1, b1):
		# print("--")
		if b1-a1 < t1:
			res = b1-a1 + d01 + min(d12, (t1-(b1-a1))/2.0)
		else:
			res = d01 + t1
	elif floatEq(d02 + d01, d12):
		# print("---")
		if t1 < t2:
			res = t1 + min(d01, (t2-t1)/2.0)
		else:
			res = t2 + min(d02, (t1-t2)/2.0)
	elif floatEq(d01 + d12, d02):
		# print("----")
		if t1 < t2:
			res = d01 + t1
		else:
			res = d01 + t2 + min(d12, (t1-t2)/2.0)
	else:
		# print("-----")
		a = d01
		b = d02
		c = d12
		cosAlph = (a**2 + b**2 - c**2)/(2*a*b)
		alph = acos(cosAlph)
		sinAlph = sin(alph)
		g2 = t2+b
		g1 = t1+a
		w = (b**2-g2**2)/(a**2-g1**2)
		ap = a*w/b
		gp = (w*g1-g2)/b
		app = ap-cosAlph
		bpp = sinAlph
		
		# appp = bpp**2+app**2
		# bppp = -2*bpp*gp
		# cppp = gp**2 - bpp**2
		# d = bppp**2-4*appp*cppp
		# print(d)
		# cosAlph1 = (-bppp + sqrt(d))/(2*appp)
		# alph1 = acos(cosAlph1)
		# sinAlph1 = sin(alph1)
		# hp = (a**2-g1**2)/(2*(a*cosAlph1-g1))
		# cosAlph2 = (-bppp - sqrt(d))/(2*appp)
		# alph2 = acos(cosAlph2)
		# sinAlph2 = sin(alph2)
		# hp2 = (a**2-g1**2)/(2*(a*cosAlph2-g1))
		# if hp < hp2 and alph >= alph2 >= 0:
			# hp = hp2
			# sinAlph1 = sinAlph2
			# alph1 = alph2
			# cosAlph1 = cosAlph2
		appp = bpp**2+app**2
		bppp = 2*bpp*gp
		cppp = gp**2-app**2
		d = bppp**2-4*appp*cppp
		sinAlph1 = (-bppp + sqrt(d))/(2*appp)
		alph1 = asin(sinAlph1)
		cosAlph1 = cos(alph1)
		hp = (a**2-g1**2)/(2*(a*cosAlph1-g1))
		sinAlph2 = (-bppp - sqrt(d))/(2*appp)
		alph2 = asin(sinAlph2)
		cosAlph2 = cos(alph2)
		hp2 = (a**2-g1**2)/(2*(a*cosAlph2-g1))
		if hp2 > hp and 0 <= alph2 <= alph:
			d2 = hp2**2+a**2-2*hp2*a*cosAlph2
			ok = True
			if d2 >= 0.0:
				h2 = sqrt(hp2**2+a**2-2*hp2*a*cosAlph2)
				if not floatEq(g1, hp2+h2):
					ok = False
			else:
				ok = False
			alph2P = alph-alph2
			sinAlph2P = sin(alph2P)
			cosAlph2P = cos(alph2P)
			d2P = hp2**2+b**2-2*hp2*b*cosAlph2P
			if d2P >= 0.0:
				h2P = sqrt(hp2**2+b**2-2*hp2*b*cosAlph2P)
				if not floatEq(g2, hp2+h2P):
					ok = False
			if ok:
				hp = hp2
				sinAlph1 = sinAlph2
				alph1 = alph2
				cosAlph1 = cosAlph2
		beta1 = acos((a**2+c**2-b**2)/(2*a*c))
		gamma1 = pi - alph1 - beta1
		h = a*sin(beta1)/sin(gamma1)
		x1 = sinAlph1*a/sin(gamma1)
		x2 = c-x1
		if hp > h:
			newT1 = t1-(h+x1-a)
			newT2 = t2-(h+x2-b)
			if newT1 < 0 or newT2 < 0:
				sinAlph1 = (-bppp + sqrt(d))/(2*appp)
				alph1 = pi - asin(sinAlph1)
				cosAlph1 = cos(alph1)
				hp = (a**2-g1**2)/(2*(a*cosAlph1-g1))
				sinAlph2 = (-bppp - sqrt(d))/(2*appp)
				alph2 = pi - asin(sinAlph2)
				cosAlph2 = cos(alph2)
				hp2 = (a**2-g1**2)/(2*(a*cosAlph2-g1))
				if hp2 > hp and 0 <= alph2 <= alph:
					alph1 = alph2
					sinAlph1 = sinAlph2
					alph1 = alph2
					cosAlph1 = cosAlph2
				beta1 = acos((a**2+c**2-b**2)/(2*a*c))
				gamma1 = pi - alph1 - beta1
				h = a*sin(beta1)/sin(gamma1)
				x1 = sinAlph1*a/sin(gamma1)
				x2 = c-x1
		if hp > h:
			# print("-")
			newT1 = t1-(h+x1-a)
			newT2 = t2-(h+x2-b)
			if newT1 < newT2:
				res = h + newT1 + min(x1, (newT2-newT1)/2.0)
			else:
				res = h + newT2 + min(x2, (newT1-newT2)/2.0)
		else:
			# print("--")
			res = hp
print("{:.5f}".format(res))