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

Solution:
#include <bits/stdc++.h>
using namespace std;
int top = 0;
long double l1, l2;
struct pnt {
  long double x, y;
} p[3];
struct circ {
  pnt o;
  long double r;
} cir[3];
vector<pnt> st;
pnt operator-(const pnt &a, const pnt &b) { return pnt{a.x - b.x, a.y - b.y}; }
long double operator*(const pnt &a, const pnt &b) {
  return a.x * b.x + a.y * b.y;
}
bool operator==(const pnt &a, const pnt &b) {
  return (fabs(a.x - b.x) <= 1e-10 && fabs(a.x - b.y) <= 1e-10);
}
long double length(pnt a) { return sqrt(a * a); }
bool oncir(pnt x, circ c) { return (fabs(length(x - c.o) - c.r) <= 1e-10); }
bool inter(circ c1, circ c2) {
  long double &r1 = c1.r, &r2 = c2.r;
  long double &x1 = c1.o.x, &y1 = c1.o.y;
  long double &x2 = c2.o.x, &y2 = c2.o.y;
  long double dist = length(c1.o - c2.o);
  if (fabs(r1 - r2) - dist > 0) return true;
  if (r1 + r2 - dist < -1e-10) return false;
  long double dist2 = (c1.o - c2.o) * (c1.o - c2.o);
  long double a = r1 * (x1 - x2) * 2, b = r1 * (y1 - y2) * 2,
              c = r2 * r2 - r1 * r1 - dist * dist;
  long double p = a * a + b * b, q = -a * c * 2, r = c * c - b * b;
  long double cosa, sina, cosb, sinb;
  if (fabs(dist - (r1 + r2)) < 1e-10 || fabs(dist - fabs(r1 - r2)) < 1e-10) {
    cosa = -q / p / 2;
    sina = sqrt(1 - cosa * cosa);
    pnt p = (pnt){x1 + c1.r * cosa, y1 + c1.r * sina};
    if (!oncir(p, c2)) p.y = y1 - c1.r * sina;
    st.push_back(p);
    return true;
  }
  long double delt = sqrt(q * q - 4 * p * r);
  cosa = (-q + delt) / p / 2;
  cosb = (-q - delt) / p / 2;
  sina = sqrt(1 - cosa * cosa);
  sinb = sqrt(1 - cosb * cosb);
  pnt p1 = pnt{x1 + c1.r * cosa, y1 + c1.r * sina};
  if (!oncir(p1, c2)) p1.y = y1 - c1.r * sina;
  pnt p2 = pnt{x1 + c1.r * cosb, y1 + c1.r * sinb};
  if (!oncir(p2, c2)) p2.y = y1 - c1.r * sinb;
  if (p1 == p2) p1.y = y1 - c1.r * sina;
  st.push_back(p1), st.push_back(p2);
  return true;
}
bool incl(circ c1, circ c2) {
  long double dist = length(c1.o - c2.o);
  if (fabs(c1.r - c2.r) - dist > 1e-10)
    return true;
  else
    return false;
}
bool incrc(pnt x) {
  for (int i = 0; i < 3; i++) {
    long double dist = length(x - cir[i].o);
    if (dist - cir[i].r > 1e-10) return false;
  }
  return true;
}
bool check() {
  st.clear();
  for (int i = 0; i < 3; i++)
    for (int j = i + 1; j < 3; j++)
      if (!inter(cir[i], cir[j])) return false;
  for (int i = 0; i < 3; i++)
    for (int j = i + 1; j < 3; j++)
      if (incl(cir[i], cir[j])) return true;
  for (int i = 0; i < st.size(); i++) {
    pnt t = st[i];
    if (incrc(t)) return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(15);
  cin >> l1 >> l2;
  for (int i = 0; i < 3; i++) cin >> p[i].x >> p[i].y;
  long double ab = length(p[1] - p[0]), ac = length(p[2] - p[0]),
              bc = length(p[2] - p[1]);
  l1 += ac + bc, l2 += ab;
  if (l2 - ac - bc >= -1e-10) return !(cout << min(l1, l2) << endl);
  long double l = 0, r = min(l1 - bc, l2);
  for (int i = 0; i < 300; i++) {
    long double mid = (l + r) / 2.0;
    cir[0].o = p[0], cir[0].r = mid;
    cir[1].o = p[1], cir[1].r = l2 - mid;
    cir[2].o = p[2], cir[2].r = l1 - bc - mid;
    if (check())
      l = mid;
    else
      r = mid;
  }
  cout << l << endl;
  return 0;
}