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 = 6e-10;
const int INF = 987654321;
double t1, t2, l, r, mid;
struct point {
  double x, y;
};
struct circle {
  double r;
  point p;
  double c, d, e;
} c1, c2, c3;
struct line {
  double a, b, c;
};
inline double sqr(double x) { return x * x; }
inline void change(circle &c) {
  c.c = -c.p.x * 2;
  c.d = -c.p.y * 2;
  c.e = sqr(c.p.x) + sqr(c.p.y) - sqr(c.r);
}
inline double getDis(point a, point b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
inline double getDis(point p, line l) {
  return fabs(l.a * p.x + l.b * p.y + l.c) / sqrt(l.a * l.a + l.b * l.b);
}
inline int pointAndCircle(point p, circle c) {
  if (getDis(p, c.p) - c.r > eps) return 0;
  if (fabs(getDis(p, c.p) - c.r) <= eps) return 1;
  return 2;
}
inline int lineAndCircle(line l, circle c) {
  if (getDis(c.p, l) - c.r > eps) return 0;
  if (fabs(getDis(c.p, l) - c.r) <= eps) return 1;
  return 2;
}
inline int circleAndCircle(circle c1, circle c2) {
  if (getDis(c1.p, c2.p) - c1.r - c2.r > eps) return 0;
  if (fabs(getDis(c1.p, c2.p) - c1.r - c2.r) <= eps) return 1;
  if (c1.r - getDis(c1.p, c2.p) - c2.r > eps) return 3;
  if (c2.r - getDis(c1.p, c2.p) - c1.r > eps) return 4;
  return 2;
}
inline int jyyecfc(double a, double b, double c, double &x1, double &x2) {
  if (fabs(a) <= eps && fabs(b) <= eps && fabs(c) <= eps) return INF;
  if (fabs(a) <= eps && fabs(b) <= eps) return 0;
  if (fabs(a) <= eps) {
    x1 = -c / b;
    return 1;
  }
  double d = b * b - a * c * 4;
  if (d < -eps) return 0;
  if (fabs(d) <= eps) {
    x1 = -b / a / 2;
    return 1;
  }
  x1 = (-b + sqrt(d)) / a / 2;
  x2 = (-b - sqrt(d)) / a / 2;
  return 2;
}
inline int lineCutCircle(line l, circle c, point &p1, point &p2) {
  int x = lineAndCircle(l, c);
  if (x == 0) return 0;
  double x1, x2;
  if (l.a == 0) {
    jyyecfc(1, c.c, c.e + c.d * (-l.c / l.b) + sqr(-l.c / l.b), x1, x2);
    p1.x = x1;
    p1.y = p2.y = -l.c / l.b;
    p2.x = x2;
  } else if (l.b == 0) {
    jyyecfc(1, c.d, c.e + c.c * (-l.c / l.a) + sqr(-l.c / l.a), x1, x2);
    p1.x = p2.x = -l.c / l.a;
    p1.y = x1;
    p2.y = x2;
  } else {
    jyyecfc(1 + sqr(l.a / l.b),
            c.c + l.a * l.c * 2 / l.b / l.b - l.a * c.d / l.b,
            c.e + sqr(l.c / l.b) - l.c * c.d / l.b, x1, x2);
    p1.x = x1;
    p1.y = -l.a * x1 / l.b - l.c / l.b;
    p2.x = x2;
    p2.y = -l.a * x2 / l.b - l.c / l.b;
  }
  return x;
}
inline int circleCutCircle(circle c1, circle c2, point &p1, point &p2) {
  line l;
  l.a = c1.c - c2.c;
  l.b = c1.d - c2.d;
  l.c = c1.e - c2.e;
  return lineCutCircle(l, c2, p1, p2);
}
inline bool isok(double x) {
  c1.r = x;
  c2.r = getDis(c1.p, c2.p) + t2 - x;
  c3.r = getDis(c1.p, c3.p) + t1 - x;
  if (x < -eps || c2.r < -eps || c3.r < -eps) return 0;
  change(c1);
  change(c2);
  change(c3);
  int o1 = circleAndCircle(c1, c2), o2 = circleAndCircle(c1, c3),
      o3 = circleAndCircle(c2, c3);
  if (o1 == 0 || o2 == 0 || o3 == 0) return 0;
  if (o1 > 2 || o2 > 2 || o3 > 2) return 1;
  point a, b, c, d, e, f;
  o1 = circleCutCircle(c1, c2, a, b);
  o2 = circleCutCircle(c1, c3, c, d);
  o3 = circleCutCircle(c2, c3, e, f);
  if (pointAndCircle(a, c3) || o1 == 2 && pointAndCircle(b, c3)) return 1;
  if (pointAndCircle(c, c2) || o2 == 2 && pointAndCircle(d, c2)) return 1;
  if (pointAndCircle(e, c1) || o3 == 2 && pointAndCircle(f, c1)) return 1;
  return 0;
}
int main() {
  scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &t1, &t2, &c1.p.x, &c1.p.y, &c2.p.x,
        &c2.p.y, &c3.p.x, &c3.p.y);
  if (getDis(c1.p, c3.p) + getDis(c3.p, c2.p) - getDis(c1.p, c2.p) - t2 <= eps)
    printf("%.10lf", min(getDis(c1.p, c3.p) + getDis(c3.p, c2.p) + t1,
                         getDis(c1.p, c2.p) + t2));
  else {
    l = 0;
    r = min(getDis(c1.p, c3.p) + getDis(c3.p, c2.p) + t1,
            getDis(c1.p, c2.p) + t2);
    while (r - l > eps) {
      mid = (l + r) / 2;
      if (isok(mid))
        l = mid;
      else
        r = mid;
    }
    printf("%.10lf", mid);
  }
}