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;
class Point;
class Circle;
int get_deviation(long double a, long double b);
long double mysqrt(long double x);
long double ldabs(long double x);
long double ldmax(long double a, long double b);
long double ldmin(long double a, long double b);
class Point {
 public:
  long double x, y;

 public:
  Point(long double i, long double j) : x(i), y(j) {}
  Point() {}

 public:
  long double length2() const;
  long double length() const;
  bool is_in(const Circle &C) const;

 public:
  friend Point operator-(const Point &A, const Point &B);
  friend Point operator/(const Point &A, const Point &B);
  friend bool operator==(const Point &A, const Point &B);
  friend bool operator!=(const Point &A, const Point &B);
  friend long double get_distance(const Point &A, const Point &B);
  friend long double get_dot(const Point &A, const Point &B);
  friend bool have_intersection(Circle A, Circle B, Circle C);
};
class Circle {
 public:
  Point center;
  long double radius;

 public:
  Circle(Point c, long double r) : center(c), radius(r) {}
  Circle() {}

 public:
  friend bool have_intersection(Circle A, Circle B, Circle C);
};
long double solve();
bool check();
const long double EPS = 1e-14;
long double t1, t2;
long double d_cs, d_sh, d_ch;
long double d1, d2;
Point cinema, house, shop;
Circle circles[3];
int main() {
  cout << fixed << setprecision(10);
  cin >> t1 >> t2 >> cinema.x >> cinema.y >> house.x >> house.y >> shop.x >>
      shop.y;
  d_cs = get_distance(cinema, shop);
  d_sh = get_distance(shop, house);
  d_ch = get_distance(cinema, house);
  d1 = d_cs + d_sh;
  d2 = d_ch;
  long double res = solve();
  cout << res << endl;
  return 0;
}
long double solve() {
  if (d2 + t2 >= d1) {
    return ldmin(d1 + t1, d2 + t2);
  }
  long double left = 0, right = ldmin(d1 + t1 - d_sh, d2 + t2);
  while (get_deviation(left, right) < 0) {
    long double mid = (left + right) / 2;
    circles[0] = Circle(cinema, mid);
    circles[1] = Circle(house, d_ch + t2 - mid);
    circles[2] = Circle(shop, d_cs + t1 - mid);
    if (check())
      left = mid;
    else
      right = mid;
  }
  return left;
}
int dcmp(long double x) {
  if (fabs(x) < EPS) return 0;
  return x > 0.0 ? 1 : -1;
}
long double sqr(long double t) { return t * t; }
long double GetDist(long double x1, long double y1, long double x2,
                    long double y2) {
  return sqrt(sqr(x1 - x2) + sqr(y2 - y1));
}
long double GetSqrDist(long double x1, long double y1, long double x2,
                       long double y2) {
  return sqr(x1 - x2) + sqr(y2 - y1);
}
bool Seperated(Point o1, long double r1, Point o2, long double r2) {
  if (dcmp(GetSqrDist(o1.x, o1.y, o2.x, o2.y) - sqr(r1 + r2)) == 1) return true;
  return false;
}
long double Include(Point o1, long double r1, Point o2, long double r2) {
  if (dcmp(GetSqrDist(o1.x, o1.y, o2.x, o2.y) - sqr(fabs(r1 - r2))) <= 0)
    return true;
  return false;
}
bool check() {
  for (int i = 0; i < 3; i++)
    for (int j = i + 1; j < 3; j++) {
      Circle A = circles[i];
      Circle B = circles[j];
      long double delta = (A.center - B.center).length();
      long double rasum = ldabs(A.radius + B.radius);
      if (get_deviation(delta, rasum) > 0) return false;
    }
  for (int i = 0; i < 3; i++)
    for (int j = i + 1; j < 3; j++) {
      Circle A = circles[i];
      Circle B = circles[j];
      long double delta = (A.center - B.center).length();
      long double radelta = ldabs(A.radius - B.radius);
      if (get_deviation(delta, radelta) < 0) return true;
    }
  for (int i = 0; i < 3; i++) {
    int j = (i + 1) % 3;
    int k = (i + 2) % 3;
    if (have_intersection(circles[i], circles[j], circles[k])) return true;
  }
  return false;
}
int get_deviation(long double a, long double b) {
  long double delta = a - b;
  if (ldabs(delta) < EPS) return 0;
  return (delta > 0 ? 1 : -1);
}
long double ldabs(long double x) { return (x >= 0 ? x : -x); }
long double ldmax(long double a, long double b) { return (a > b ? a : b); }
long double ldmin(long double a, long double b) { return (a < b ? a : b); }
void trif_limit(long double cosx) {
  cosx = ldmax(ldmin(cosx, (long double)1.0), (long double)-1.0);
}
long double Point::length2() const { return x * x + y * y; }
long double Point::length() const { return sqrt(length2()); }
bool Point::is_in(const Circle &C) const {
  long double delta = (C.center - *this).length();
  return (get_deviation(delta, C.radius) <= 0);
}
Point operator-(const Point &A, const Point &B) {
  return Point(A.x - B.x, A.y - B.y);
}
Point operator/(const Point &A, const Point &B) {
  Point P(A.x * B.x + A.y * B.y, A.y * B.x - A.x * B.y);
  P.x /= B.length2();
  P.y /= B.length2();
  return P;
}
bool operator==(const Point &A, const Point &B) {
  return (get_deviation(A.x, B.x) == 0 && get_deviation(A.y, B.y) == 0);
}
bool operator!=(const Point &A, const Point &B) { return !(A == B); }
long double get_distance(const Point &A, const Point &B) {
  return (A - B).length();
}
long double get_dot(const Point &A, const Point &B) {
  return (A.x * B.x + A.y * B.y);
}
bool InCircle(Point o, Circle A, Circle B, Circle C) {
  Point o1 = A.center, o2 = B.center, o3 = C.center;
  long double r1 = A.radius, r2 = B.radius, r3 = C.radius;
  if (dcmp(GetSqrDist(o.x, o.y, o1.x, o1.y) - sqr(r1)) == 1) return false;
  if (dcmp(GetSqrDist(o.x, o.y, o2.x, o2.y) - sqr(r2)) == 1) return false;
  if (dcmp(GetSqrDist(o.x, o.y, o3.x, o3.y) - sqr(r3)) == 1) return false;
  return true;
}
bool new_have_intersection(Circle A, Circle B, Circle C) {
  long double delta = (A.center - B.center).length();
  Point o1 = A.center, o2 = B.center;
  long double r1 = A.radius, r2 = B.radius;
  Point A1, A2;
  long double d, a, b, c, p, q, r;
  long double cos_value[2], sin_value[2];
  d = GetDist(o1.x, o1.y, o2.x, o2.y);
  a = 2.0 * r1 * (o1.x - o2.x);
  b = 2.0 * r1 * (o1.y - o2.y);
  c = r2 * r2 - r1 * r1 - GetSqrDist(o1.x, o1.y, o2.x, o2.y);
  p = a * a + b * b;
  q = -2.0 * a * c;
  if (dcmp(d - (r1 + r2)) == 0 || dcmp(d - fabs(r1 - r2)) == 0) {
    cos_value[0] = -q / p / 2.0;
    sin_value[0] = sqrt(1 - cos_value[0] * cos_value[0]);
    A1.x = r1 * cos_value[0] + o1.x;
    A1.y = r1 * sin_value[0] + o1.y;
    if (dcmp(GetSqrDist(A1.x, A1.y, o2.x, o2.y) - sqr(r2)) != 0) {
      A1.y = o1.y - r1 * sin_value[0];
    }
    A2 = A1;
    if (InCircle(A1, A, B, C)) return true;
    if (InCircle(A2, A, B, C)) return true;
    return false;
  }
  r = c * c - b * b;
  cos_value[0] = (sqrt(q * q - 4.0 * p * r) - q) / p / 2.0;
  cos_value[1] = (-sqrt(q * q - 4.0 * p * r) - q) / p / 2.0;
  sin_value[0] = sqrt(1 - cos_value[0] * cos_value[0]);
  sin_value[1] = sqrt(1 - cos_value[1] * cos_value[1]);
  A1.x = r1 * cos_value[0] + o1.x;
  A2.x = r1 * cos_value[1] + o1.x;
  A1.y = r1 * sin_value[0] + o1.y;
  A2.y = r1 * sin_value[1] + o1.y;
  if (dcmp(GetSqrDist(A1.x, A1.y, o2.x, o2.y) - r2 * r2) != 0)
    A1.y = o1.y - r1 * sin_value[0];
  if (dcmp(GetSqrDist(A2.x, A2.y, o2.x, o2.y) - r2 * r2) != 0)
    A2.y = o1.y - r1 * sin_value[1];
  if (dcmp(A1.y - A2.y) == 0 && dcmp(A1.x - A2.x) == 0) {
    if (A1.y > 0)
      A2.y = -A2.y;
    else
      A1.y = -A1.y;
  }
  if (InCircle(A1, A, B, C)) return true;
  if (InCircle(A2, A, B, C)) return true;
  return false;
}
bool ac_have_intersection(Circle A, Circle B, Circle C) {
  if ((A.center - C.center).length() <= A.radius &&
      (B.center - C.center).length() <= B.radius)
    return true;
  B.center = B.center - A.center;
  C.center = C.center - A.center;
  A.center = A.center - A.center;
  Point R(B.center.x / B.center.length(), B.center.y / B.center.length());
  B.center = B.center / R;
  C.center = C.center / R;
  long double x =
      (A.radius * A.radius - B.radius * B.radius + B.center.length2()) /
      (2 * B.center.length());
  long double y = sqrt(max(A.radius * A.radius - x * x, (long double)0.0));
  Point p1(x, y), p2(x, -y);
  if (get_deviation(y * y + (B.center.length() - x) * (B.center.length() - x),
                    B.radius * B.radius) != 0)
    return false;
  if ((p1 - C.center).length() <= C.radius ||
      (p2 - C.center).length() <= C.radius)
    return true;
  return false;
}
bool wa_have_intersection(Circle A, Circle B, Circle C) {
  long double delta = (A.center - B.center).length();
  int dev_in = get_deviation(delta, abs(A.radius - B.radius));
  int dev_out = get_deviation(delta, abs(A.radius + B.radius));
  if (dev_in < 0) return true;
  if (dev_out > 0) return false;
  long double cosa = (B.center.x - A.center.x) / delta;
  long double cosb =
      (A.radius * A.radius + delta * delta - B.radius * B.radius) /
      (2 * A.radius * delta);
  trif_limit(cosa);
  trif_limit(cosb);
  long double sina = sqrt(1 - cosa * cosa);
  long double sinb = sqrt(1 - cosb * cosb);
  trif_limit(sina);
  trif_limit(sinb);
  long double cosS1 = cosa * cosb - sina * sinb;
  long double cosS2 = cosa * cosb + sina * sinb;
  trif_limit(cosS1);
  trif_limit(cosS2);
  long double sinS1 = sqrt(1 - cosS1 * cosS1);
  long double sinS2 = sqrt(1 - cosS2 * cosS2);
  trif_limit(sinS1);
  trif_limit(sinS2);
  Point p1(A.center.x + A.radius * cosS1, A.center.y + A.radius * sinS1);
  Point p2(A.center.x + A.radius * cosS2, A.center.y + A.radius * sinS2);
  if (p1.is_in(C) || p2.is_in(C)) return true;
  return false;
}
bool have_intersection(Circle A, Circle B, Circle C) {
  return new_have_intersection(A, B, C);
}