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() {}
  Point rotate90() const { return Point(-y, x); }
  friend inline long double get_distance2(const Point &A, const Point &B) {
    Point v = B - A;
    return (v * v);
  }
  friend inline long double get_distance(const Point &A, const Point &B) {
    Point v = B - A;
    return sqrt(v * v);
  }
  friend Point operator+(const Point &A, const Point &B) {
    return Point(A.x + B.x, A.y + B.y);
  }
  friend Point operator-(const Point &A, const Point &B) {
    return Point(A.x - B.x, A.y - B.y);
  }
  friend Point operator*(const Point &P, long double t) {
    return Point(P.x * t, P.y * t);
  }
  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);
  }
  friend bool operator!=(const Point &A, const Point &B) { return !(A == B); }
};
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(C, d1 + t1 - mid - cb);
    circles[2] = Circle(B, d2 + t2 - 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[j], circles[i], 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) {
  inters.clear();
  Point o1 = C1.center, o2 = C2.center;
  long double r1 = C1.radius, r2 = C2.radius;
  long double d2 = get_distance2(o1, o2);
  long double d = get_distance(o1, o2);
  if (sign((r1 + r2) - d) < 0) return 0;
  if (sign(ldabs(r1 - r2) - d) > 0) return -1;
  long double t1 = (r1 * r1 - r2 * r2) / (2 * d2) + 0.5;
  long double t2 = r1 * r1 / d2 - t1 * t1;
  t2 = t2 < 0 ? 0 : sqrt(t2);
  Point foot = o1 + (o2 - o1) * t1;
  Point ret1 = foot + (o2 - o1).rotate90() * t2;
  Point ret2 = foot * 2 - ret1;
  inters.push_back(ret1);
  if (ret1 != ret2) inters.push_back(ret2);
  return (ret1 != ret2 ? 2 : 1);
}