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 EPS = 1e-14;
inline int sign(long double x) { return (abs(x) < EPS ? 0 : (x > 0 ? 1 : -1)); }
inline long double ldabs(long double x) { return (x >= 0 ? x : -x); }
inline long double ldmax(long double a, long double b) {
  return (a > b ? a : b);
}
inline long double ldmin(long double a, long double b) {
  return (a < b ? a : b);
}
class Point {
 public:
  long double x, y;
  Point(long double i, long double j) : x(i), y(j) {}
  Point() {}
  friend inline long double get_distance2(const Point &A, const Point &B) {
    return ((A - B) * (A - B));
  }
  friend inline long double get_distance(const Point &A, const Point &B) {
    return sqrt(get_distance2(A, B));
  }
  friend Point operator-(const Point &A, const Point &B) {
    return Point(A.x - B.x, A.y - B.y);
  }
  friend long double operator*(const Point &A, const Point &B) {
    return (A.x * B.x + A.y * B.y);
  }
  friend long double operator^(const Point &A, const Point &B) {
    return (A.x * B.y - B.x * A.y);
  }
  friend bool operator==(const Point &A, const Point &B) {
    return (sign(A.x - B.x) == 0 && sign(A.y - B.y) == 0);
  }
};
class Circle {
 public:
  Point center;
  long double radius;
  Circle(const Point &P, long double r) : center(P), radius(r) {}
  Circle() {}
};
long double solve();
bool check();
bool have_intersection(const Circle &A, const Circle &B, const Circle &C);
bool is_on_circle(const Point &P, const Circle &C);
bool is_in_circle(const Point &P, const Circle &C);
bool is_separated(const Circle &C1, const Circle &C2);
bool is_included(const Circle &C1, const Circle &C2);
int get_intersection(const Circle &C1, const Circle &C2, vector<Point> &inters);
long double t1, t2;
Point cinema, house, shop;
Circle circles[3];
int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while (cin >> t1 >> t2 >> cinema.x >> cinema.y >> house.x >> house.y >>
         shop.x >> shop.y) {
    long double res = solve();
    cout << res << endl;
  }
  return 0;
}
long double solve() {
  Point &A = cinema, &B = house, &C = shop;
  long double ac = get_distance(A, C);
  long double cb = get_distance(C, B);
  long double ab = get_distance(A, B);
  long double d1 = ac + cb;
  long double d2 = ab;
  if (d2 + t2 >= d1) {
    return ldmin(d1 + t1, d2 + t2);
  }
  long double left = 0, right = ldmin(d1 + t1 - cb, d2 + t2);
  for (int i = 1; i <= 100; i++) {
    long double mid = (left + right) / 2;
    circles[0] = Circle(A, mid);
    circles[1] = Circle(B, ab + t2 - mid);
    circles[2] = Circle(C, ac + t1 - mid);
    if (check())
      left = mid;
    else
      right = mid;
  }
  return left;
}
bool check() {
  for (int i = 0; i < 3; i++) {
    int j = (i + 1) % 3;
    if (is_separated(circles[i], circles[j])) return false;
  }
  for (int i = 0; i < 3; i++) {
    int j = (i + 1) % 3;
    if (is_included(circles[i], circles[j])) 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;
}
bool have_intersection(const Circle &A, const Circle &B, const Circle &C) {
  vector<Point> inters;
  int cnt = get_intersection(A, B, inters);
  if (cnt == 1) {
    Point &P = inters[0];
    if (is_in_circle(P, A) && is_in_circle(P, B) && is_in_circle(P, C))
      return true;
    return false;
  }
  Point &P1 = inters[0], &P2 = inters[1];
  if (is_in_circle(P1, A) && is_in_circle(P1, B) && is_in_circle(P1, C))
    return true;
  if (is_in_circle(P2, A) && is_in_circle(P2, B) && is_in_circle(P2, C))
    return true;
  return false;
}
inline bool is_on_circle(const Point &P, const Circle &C) {
  return (sign(get_distance2(P, C.center) - C.radius * C.radius) == 0);
}
inline bool is_in_circle(const Point &P, const Circle &C) {
  return (sign(get_distance2(P, C.center) - C.radius * C.radius) <= 0);
}
inline bool is_separated(const Circle &C1, const Circle &C2) {
  long double d = get_distance(C1.center, C2.center);
  return (sign((C1.radius + C2.radius) - d) < 0);
}
inline bool is_included(const Circle &C1, const Circle &C2) {
  long double d = get_distance(C1.center, C2.center);
  return (sign(ldabs(C1.radius - C2.radius) - d) > 0);
}
int get_intersection(const Circle &C1, const Circle &C2,
                     vector<Point> &inters) {
  if (is_separated(C1, C2)) return 0;
  if (is_included(C1, C2)) return -1;
  inters.clear();
  long double r1 = C1.radius, r2 = C2.radius;
  long double x1 = C1.center.x, y1 = C1.center.y;
  long double x2 = C2.center.x, y2 = C2.center.y;
  long double d = get_distance(C1.center, C2.center);
  long double sqr_d = (C1.center - C2.center) * (C1.center - C2.center);
  long double a = 2 * r1 * (x1 - x2), b = 2 * r1 * (y1 - y2),
              c = r2 * r2 - r1 * r1 - sqr_d;
  long double A = a * a + b * b, B = -2 * a * c, C = c * c - b * b;
  if (sign((r1 + r2) - d) == 0 || sign(abs(r1 - r2) - d) == 0) {
    long double sumx = -B / A;
    long double cosa = sumx / 2, sina = sqrt(1 - cosa * cosa);
    Point P(x1 + r1 * cosa, y1 + r1 * sina);
    if (!is_on_circle(P, C2)) P.y = y1 - r1 * sina;
    inters.push_back(P);
    return 1;
  }
  long double delta = sqrt(B * B - 4 * A * C);
  long double cosa = (-B + delta) / A / 2, cosb = (-B - delta) / A / 2;
  long double sina = sqrt(1 - cosa * cosa), sinb = sqrt(1 - cosb * cosb);
  Point P1(x1 + r1 * cosa, y1 + r1 * sina);
  if (!is_on_circle(P1, C2)) P1.y = y1 - r1 * sina;
  Point P2(x1 + r1 * cosb, y1 + r1 * sinb);
  if (!is_on_circle(P2, C2) || P1 == P2) P2.y = y1 - r1 * sinb;
  inters.push_back(P1);
  inters.push_back(P2);
  return 2;
}