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 double eps = 1e-10;
struct point {
  double x, y;
  point() { x = y = 0.0; }
  point(double x, double y) : x(x), y(y) {}
};
struct circle {
  double r;
  point O;
  circle() { O.x = O.y = r = 0.0; }
  circle(point O, double r) : O(O), r(r) {}
  point ang(double a) { return point(O.x + cos(a) * r, O.y + sin(a) * r); }
};
point operator-(point a, point b) { return point(a.x - b.x, a.y - b.y); }
double dist(point a) { return sqrt(a.x * a.x + a.y * a.y); }
double t1, t2, d1, d2, d3;
point a, b, c, D, E;
circle A, B, C;
int dcmp(double a) {
  if (fabs(a) < eps) return 0;
  return a > eps ? 1 : -1;
}
double angle(point v) { return atan2(v.y, v.x); }
int flag;
bool jiao(circle C1, circle C2) {
  flag = 0;
  double d = dist(C1.O - C2.O);
  if (dcmp(C1.r + C2.r - d) < 0) return false;
  if (dcmp(C1.r - C2.r - d) > 0) {
    flag = 1;
    return false;
  }
  if (dcmp(C2.r - C1.r - d) > 0) {
    flag = 2;
    return false;
  }
  double a = angle(C2.O - C1.O);
  double da =
      acos((C1.r * C1.r + d * d - C2.r * C2.r) / (2 * C1.r * d) - 1e-12);
  D = C1.ang(a - da), E = C1.ang(a + da);
  return true;
}
int aa, bb, cc;
bool check(double x) {
  A = circle(a, x);
  B = circle(b, d1 + t1 - x);
  C = circle(c, d2 + t2 - x);
  aa = 0, bb = 0, cc = 0;
  if (jiao(A, B)) {
    if (dcmp(C.r - dist(D - C.O)) >= 0) return true;
    if (dcmp(C.r - dist(E - C.O)) >= 0) return true;
  }
  if (flag == 1) bb++;
  if (flag == 2) aa++;
  if (jiao(A, C)) {
    double dis = dist(D - C.O);
    if (dcmp(B.r - dist(D - B.O)) >= 0) return true;
    if (dcmp(B.r - dist(E - B.O)) >= 0) return true;
  }
  if (flag == 1) cc++;
  if (flag == 2) aa++;
  if (jiao(B, C)) {
    if (dcmp(A.r - dist(D - A.O)) >= 0) return true;
    if (dcmp(A.r - dist(E - A.O)) >= 0) return true;
  }
  if (flag == 1) cc++;
  if (flag == 2) bb++;
  if (aa == 2 || bb == 2 || cc == 2) return true;
  return false;
}
int main() {
  scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &t1, &t2, &a.x, &a.y, &c.x, &c.y,
        &b.x, &b.y);
  d1 = dist(a - b);
  d2 = dist(a - c), d3 = dist(b - c);
  double l = 0, r = min(d1 + t1, d2 + t2), m;
  while (dcmp(l - r)) {
    double m = (l + r) / 2.0;
    if (check(m))
      l = m;
    else
      r = m - eps;
  }
  if (dcmp(d1 + d3 - t2 - d2) <= 0) l = min(d2 + t2, d1 + d3 + t1);
  printf("%.9lf\n", l);
  return 0;
}