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-10;
int dcmp(long double x) {
  if (fabs(x) < eps) return 0;
  return x < 0 ? -1 : 1;
}
long double sqr(long double x) { return x * x; }
struct Point {
  long double x, y;
  Point(long double x = 0, long double y = 0) : x(x), y(y) {}
  void read() { cin >> x >> y; }
};
Point operator-(const Point& A, const Point& B) {
  return Point(A.x - B.x, A.y - B.y);
}
bool operator==(const Point& A, const Point& B) {
  return dcmp(A.x - B.x) == 0 && dcmp(A.y - B.y) == 0;
}
long double Dot(const Point& A, const Point& B) {
  return A.x * B.x + A.y * B.y;
}
long double Length(const Point& A) { return sqrt(Dot(A, A)); }
long double angle(const Point& A) { return atan2(A.y, A.x); }
struct Circle {
  Point c;
  long double r;
  Circle() {}
  Circle(Point c, long double r) : c(c), r(r) {}
  Point point(long double a) {
    return Point(c.x + cos(a) * r, c.y + sin(a) * r);
  }
};
long double t1, t2, T1, T2;
Point p[3];
Circle o[3];
vector<Point> inter;
bool OnCircle(Point p, Circle C) { return dcmp(Length(p - C.c) - C.r) == 0; }
bool getCircleIntersection(Circle C1, Circle C2) {
  long double &r1 = C1.r, &r2 = C2.r;
  long double &x1 = C1.c.x, &x2 = C2.c.x, &y1 = C1.c.y, &y2 = C2.c.y;
  long double d = Length(C1.c - C2.c);
  if (dcmp(fabs(r1 - r2) - d) > 0) return true;
  if (dcmp(r1 + r2 - d) < 0) return false;
  long double d2 = Dot(C1.c - C2.c, C1.c - C2.c);
  long double a = r1 * (x1 - x2) * 2, b = r1 * (y1 - y2) * 2,
              c = r2 * r2 - r1 * r1 - d * d;
  long double p = a * a + b * b, q = -a * c * 2, r = c * c - b * b;
  long double cosa, sina, cosb, sinb;
  if (dcmp(d - (r1 + r2)) == 0 || dcmp(d - fabs(r1 - r2)) == 0) {
    cosa = -q / p / 2;
    sina = sqrt(1 - sqr(cosa));
    Point p(x1 + C1.r * cosa, y1 + C1.r * sina);
    if (!OnCircle(p, C2)) p.y = y1 - C1.r * sina;
    inter.push_back(p);
    return true;
  }
  long double delta = sqrt(q * q - p * r * 4);
  cosa = (delta - q) / p / 2;
  cosb = (-delta - q) / p / 2;
  sina = sqrt(1 - sqr(cosa));
  sinb = sqrt(1 - sqr(cosb));
  Point p1(x1 + C1.r * cosa, y1 + C1.r * sina);
  Point p2(x1 + C1.r * cosb, y1 + C1.r * sinb);
  if (!OnCircle(p1, C2)) p1.y = y1 - C1.r * sina;
  if (!OnCircle(p2, C2)) p2.y = y1 - C1.r * sinb;
  if (p1 == p2) p1.y = y1 - C1.r * sina;
  inter.push_back(p1);
  inter.push_back(p2);
  return true;
}
bool Include(Circle C1, Circle C2) {
  long double d = Length(C1.c - C2.c);
  if (dcmp(fabs(C1.r - C2.r) - d) > 0) return true;
  return false;
}
bool InAllCircle(const Point& t) {
  for (int i = 0; i < 3; i++) {
    long double d = Length(t - o[i].c);
    if (dcmp(d - o[i].r) > 0) return false;
  }
  return true;
}
bool check() {
  inter.clear();
  for (int i = 0; i < 3; i++)
    for (int j = i + 1; j < 3; j++)
      if (!getCircleIntersection(o[i], o[j])) return false;
  for (int i = 0; i < 3; i++)
    for (int j = i + 1; j < 3; j++)
      if (Include(o[i], o[j])) return true;
  for (Point t : inter)
    if (InAllCircle(t)) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  cin >> t1 >> t2;
  for (int i = 0; i < 3; i++) p[i].read();
  long double AB = Length(p[1] - p[0]);
  long double AC = Length(p[2] - p[0]);
  long double BC = Length(p[2] - p[1]);
  T1 = AC + BC + t1;
  T2 = AB + t2;
  if (dcmp(T2 - AC - BC) >= 0) {
    cout << min(T1, T2) << endl;
    return 0;
  }
  long double L = 0, R = min(T1 - BC, T2);
  for (int i = 0; i < 100; i++) {
    long double mid = (L + R) / 2.0;
    o[0] = Circle(p[0], mid);
    o[1] = Circle(p[1], T2 - mid);
    o[2] = Circle(p[2], T1 - BC - mid);
    if (check())
      L = mid;
    else
      R = mid;
  }
  cout << L << endl;
  return 0;
}