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-15;
const long double INF = 1e18;
inline long double fix(long double tar) { return fabs(tar) <= EPS ? 0 : tar; }
struct Point {
  long double x, y;
  Point() {}
  Point(long double x_, long double y_) { x = x_, y = y_; }
  Point operator+(const Point &b) { return Point(x + b.x, y + b.y); }
  Point operator-(const Point &b) { return Point(x - b.x, y - b.y); }
  long double arctan() { return atan2(y, x); }
} A, B, C, plist[16];
long double dist(const Point &a, const Point &b) {
  return sqrt((b.y - a.y) * (b.y - a.y) + (b.x - a.x) * (b.x - a.x));
}
struct Circle {
  Point p;
  long double r;
  Circle() {}
  Circle(Point p_, long double r_) { p = p_, r = r_; }
  Circle(long double x, long double y, long double r_) {
    p.x = x, p.y = y, r = r_;
  }
  bool in_circle(const Point &b) { return fix(dist(p, b) - r) <= 0; }
  bool tot_in_circle(const Circle &b) {
    return (fix(dist(p, b.p) + r - b.r) <= 0);
  }
} clist[8];
long double ta, tb;
inline bool circle_cross(Circle a, Circle b, Point &c, Point &d) {
  Point ab = b.p - a.p;
  long double tria = a.r, tric = b.r;
  long double trib = dist(a.p, b.p);
  if (not(fix(tria + tric - trib) >= 0 and fix(trib + tric - tria) >= 0 and
          fix(tria + trib - tric) >= 0)) {
    if (a.tot_in_circle(b) or b.tot_in_circle(a)) return true;
    return false;
  }
  long double alpha = ab.arctan();
  long double tmp = (tria * tria + trib * trib - tric * tric) /
                    ((long double)2.0 * tria * trib);
  long double delta;
  if (fix(tmp - 1.0) == 0)
    delta = 0;
  else
    delta = acos((tria * tria + trib * trib - tric * tric) /
                 ((long double)2.0 * tria * trib));
  c = a.p + Point(tria * cos(alpha + delta), tria * sin(alpha + delta));
  d = a.p + Point(tria * cos(alpha - delta), tria * sin(alpha - delta));
  return true;
}
inline bool cross(int ccnt) {
  int pcnt = 0;
  for (int i = 1; i <= ccnt; i++) {
    for (int j = i + 1; j <= ccnt; j++) {
      if (not circle_cross(clist[i], clist[j], plist[++pcnt], plist[++pcnt]))
        return false;
    }
  }
  for (int i = 1; i <= ccnt; i++) {
    for (int j = i + 1; j <= ccnt; j++) {
      if (clist[i].tot_in_circle(clist[j])) return true;
    }
  }
  for (int i = 1; i <= pcnt; i++) {
    bool in_all = true;
    for (int j = 1; j <= ccnt; j++) {
      if (not clist[j].in_circle(plist[i])) in_all = false;
    }
    if (in_all) return true;
  }
  return false;
}
inline bool judge(long double s) {
  clist[1] = Circle(A, s);
  clist[2] = Circle(B, tb - s);
  clist[3] = Circle(C, ta - dist(C, B) - s);
  if (cross(3))
    return true;
  else
    return false;
}
inline void binary_search() {
  long double le, ri, mid;
  le = 0, ri = (long double)min(tb, ta - dist(C, B));
  while (le + EPS < ri) {
    mid = (le + ri) / 2.0;
    if (judge(mid))
      le = mid;
    else
      ri = mid;
  }
  cout << fixed << setprecision(10) << (le + ri) / 2.0;
}
inline void read() {
  cin >> ta >> tb >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
}
inline void solve() {
  ta += dist(A, C) + dist(C, B);
  tb += dist(A, B);
  if (fix(dist(A, C) + dist(C, B) - tb) <= 0)
    cout << fixed << setprecision(10) << min(ta, tb) << endl;
  else
    binary_search();
}
int main() {
  read();
  solve();
  return 0;
}