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;
const long double pi = acos(-1.0), eps = 1e-10;
long double det(long double a11, long double a12, long double a21,
                long double a22) {
  return a11 * a22 - a12 * a21;
}
struct pt {
  long double x, y;
  pt(long double x, long double y) : x(x), y(y) {}
};
struct line {
  long double a, b, c;
  line(long double x1, long double y1, long double x2, long double y2) {
    a = y1 - y2;
    b = x2 - x1;
    c = a * x1 + b * y1;
  }
  line(long double a, long double b, long double c) : a(a), b(b), c(c) {}
  void transpose(pt p) { c += a * p.x + b * p.y; }
};
struct circle {
  long double x, y, r;
  circle(long double x, long double y, long double r) : x(x), y(y), r(r) {}
};
long double dist(long double x1, long double y1, long double x2,
                 long double y2) {
  long double dx = x1 - x2, dy = y1 - y2;
  return sqrt(dx * dx + dy * dy);
}
vector<pt> lineCircleIntersection(line l, pt center, long double r) {
  line t(l);
  t.transpose(pt(-center.x, -center.y));
  long double a = t.a, b = t.b, c = -t.c;
  long double x0 = -a * c / (a * a + b * b), y0 = -b * c / (a * a + b * b);
  vector<pt> res;
  if (c * c > r * r * (a * a + b * b) + eps) {
  } else if (fabs(c * c - r * r * (a * a + b * b)) < eps) {
    res.push_back(pt(x0 + center.x, y0 + center.y));
  } else {
    long double d = r * r - c * c / (a * a + b * b);
    long double mult = sqrt(d / (a * a + b * b));
    long double ax, ay, bx, by;
    ax = x0 + b * mult;
    bx = x0 - b * mult;
    ay = y0 - a * mult;
    by = y0 + a * mult;
    res.push_back(pt(ax + center.x, ay + center.y));
    res.push_back(pt(bx + center.x, by + center.y));
  }
  return res;
}
vector<pt> circleCircleIntersection(circle c1, circle c2) {
  long double x = c1.x - c2.x, y = c1.y - c2.y;
  vector<pt> res = lineCircleIntersection(
      line(2 * x, 2 * y, x * x + y * y + c2.r * c2.r - c1.r * c1.r), pt(0, 0),
      c2.r);
  for (int i = 0; i < (int)res.size(); i++) {
    res[i].x += c2.x;
    res[i].y += c2.y;
  }
  return res;
}
bool inside(pt p, circle c) { return dist(p.x, p.y, c.x, c.y) <= c.r + eps; }
bool intersects(circle c1, circle c2, circle c3) {
  c1.r += eps;
  c2.r += eps;
  c3.r += eps;
  vector<pt> p[3];
  p[0] = circleCircleIntersection(c1, c2);
  p[1] = circleCircleIntersection(c2, c3);
  p[2] = circleCircleIntersection(c3, c1);
  p[0].push_back(pt(c1.x, c1.y));
  p[1].push_back(pt(c2.x, c2.y));
  p[2].push_back(pt(c3.x, c3.y));
  for (int i = 0; i < 3; i++) {
    for (size_t j = 0; j < p[i].size(); j++) {
      if (inside(p[i][j], c1) && inside(p[i][j], c2) && inside(p[i][j], c3)) {
        return true;
      }
    }
  }
  return false;
}
long double t1, t2, cx, cy, hx, hy, sx, sy;
void solve() {
  long double d1 = dist(hx, hy, sx, sy), d2 = dist(sx, sy, cx, cy),
              d3 = dist(cx, cy, hx, hy);
  long double l1 = d1 + d2 + t1, l2 = d3 + t2;
  cout << fixed << setprecision(10);
  if (l2 >= d1 + d2) {
    cout << min(l1, l2) << endl;
  } else {
    long double L = 0, R = min(l1, l2);
    while (fabs(L - R) > eps) {
      long double r1 = (L + R) / 2, r2 = max(0. * l1, l1 - d1 - r1),
                  r3 = max(0. * l2, l2 - r1);
      if (intersects(circle(cx, cy, r1), circle(sx, sy, r2),
                     circle(hx, hy, r3))) {
        L = r1;
      } else {
        R = r1;
      }
    }
    cout << L + eps << endl;
  }
}
int main() {
  while (cin >> t1 >> t2 >> cx >> cy >> hx >> hy >> sx >> sy) {
    solve();
  }
}