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;
struct Point {
  double x, y;
};
double t1, t2;
double tab, tbc, tac;
Point pa, pb, pc;
double Distance(Point p1, Point p2) {
  return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}
Point intersection(Point u1, Point u2, Point v1, Point v2) {
  Point ret = u1;
  double t = ((u1.x - v1.x) * (v1.y - v2.y) - (u1.y - v1.y) * (v1.x - v2.x)) /
             ((u1.x - u2.x) * (v1.y - v2.y) - (u1.y - u2.y) * (v1.x - v2.x));
  ret.x += (u2.x - u1.x) * t;
  ret.y += (u2.y - u1.y) * t;
  return ret;
}
void intersection_line_circle(Point c, double r, Point l1, Point l2, Point& p1,
                              Point& p2) {
  Point p = c;
  double t;
  p.x += l1.y - l2.y;
  p.y += l2.x - l1.x;
  p = intersection(p, c, l1, l2);
  t = sqrt(r * r - Distance(p, c) * Distance(p, c)) / Distance(l1, l2);
  p1.x = p.x + (l2.x - l1.x) * t;
  p1.y = p.y + (l2.y - l1.y) * t;
  p2.x = p.x - (l2.x - l1.x) * t;
  p2.y = p.y - (l2.y - l1.y) * t;
}
void intersection_circle_circle(Point c1, double r1, Point c2, double r2,
                                Point& p1, Point& p2) {
  Point u, v;
  double t;
  t = (1 + (r1 * r1 - r2 * r2) / Distance(c1, c2) / Distance(c1, c2)) / 2;
  u.x = c1.x + (c2.x - c1.x) * t;
  u.y = c1.y + (c2.y - c1.y) * t;
  v.x = u.x + c1.y - c2.y;
  v.y = u.y - c1.x + c2.x;
  intersection_line_circle(c1, r1, u, v, p1, p2);
}
bool InCircle(Point p1, double r1, Point p2) {
  double d1 = Distance(p1, p2);
  return d1 <= r1 + 1e-10;
}
bool CircleInCircle(Point p1, double r1, Point p2, double r2) {
  double d1 = Distance(p1, p2);
  return fabs(r1 - r2) > d1;
}
bool ThreeCircleIst(Point p1, double r1, Point p2, double r2, Point p3,
                    double r3) {
  Point ist1, ist2;
  double d1 = Distance(p1, p2);
  double d2 = Distance(p2, p3);
  double d3 = Distance(p3, p1);
  r1 += 1e-10;
  r2 += 1e-10;
  r3 += 1e-10;
  if (d1 > r1 + r2) return false;
  if (d2 > r2 + r3) return false;
  if (d3 > r3 + r1) return false;
  if (CircleInCircle(p1, r1, p2, r2)) return true;
  if (CircleInCircle(p2, r2, p3, r3)) return true;
  if (CircleInCircle(p1, r1, p3, r3)) return true;
  intersection_circle_circle(p1, r1, p2, r2, ist1, ist2);
  if (InCircle(p3, r3, ist1) || InCircle(p3, r3, ist2)) return true;
  intersection_circle_circle(p2, r2, p3, r3, ist1, ist2);
  if (InCircle(p1, r1, ist1) || InCircle(p1, r1, ist2)) return true;
  intersection_circle_circle(p3, r3, p1, r1, ist1, ist2);
  if (InCircle(p2, r2, ist1) || InCircle(p2, r2, ist2)) return true;
  return false;
}
double getFunc(double ta, double tb) {
  double left, right;
  double r1, r2, r3;
  left = 0;
  right = min(ta, tb);
  while (right - left > 1e-12) {
    r1 = (left + right) / 2;
    r2 = ta - r1;
    r3 = tb - r1;
    if (ThreeCircleIst(pa, r1, pb, r2, pc, r3))
      left = r1;
    else
      right = r1;
  }
  return left;
}
int main() {
  while (scanf("%lf %lf", &t1, &t2) != EOF) {
    scanf("%lf %lf", &pa.x, &pa.y);
    scanf("%lf %lf", &pc.x, &pc.y);
    scanf("%lf %lf", &pb.x, &pb.y);
    tab = Distance(pa, pb);
    tac = Distance(pa, pc);
    tbc = Distance(pb, pc);
    if (tab + tbc - tac <= t2) {
      printf("%.6f\n", min(tab + tbc + t1, tac + t2));
      continue;
    }
    double left, right, x1, x2;
    double f1, f2;
    left = 0;
    right = min(t1, t2);
    while (right - left > 1e-10) {
      x1 = (left * 2 + right) / 3;
      x2 = (left + right * 2) / 3;
      f1 = getFunc(tab + t1 - x1, tac + t2 - x1) + x1;
      f2 = getFunc(tab + t1 - x2, tac + t2 - x2) + x2;
      if (f2 < f1)
        right = x2;
      else
        left = x1;
    }
    double ans = getFunc(tab + t1 - left, tac + t2 - left) + left;
    printf("%.6f\n", ans);
  }
  return 0;
}