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;
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void chkmax(T &a, T b) {
  if (a < b) a = b;
}
struct point {
  double x, y;
};
double dist(point P, point Q) {
  double dx = P.x - Q.x, dy = P.y - Q.y;
  return sqrt(dx * dx + dy * dy);
}
vector<point> cccross(point O1, double r1, point O2, double r2) {
  double d = dist(O1, O2);
  double t = (d * d + r1 * r1 - r2 * r2) / 2.0 / d / d;
  double fx = O1.x + (O2.x - O1.x) * t, fy = O1.y + (O2.y - O1.y) * t;
  double h = sqrt(max(r1 * r1 - t * d * t * d, 0.0));
  double dx = (O2.y - O1.y) / d * h, dy = (O1.x - O2.x) / d * h;
  vector<point> ans;
  point ans1 = {fx + dx, fy + dy};
  ans.push_back(ans1);
  point ans2 = {fx - dx, fy - dy};
  ans.push_back(ans2);
  return ans;
}
point read(void) {
  double x, y;
  scanf("%lf%lf", &x, &y);
  point P = {x, y};
  return P;
}
bool tri(double a, double b, double c) {
  double d[] = {a, b, c};
  sort(d, d + 3);
  return (d[0] + d[1] + 1.0E-12 > d[2]);
}
bool possible(point P, double p, point Q, double q, point R, double r) {
  if (dist(P, Q) < q + 1.0E-12 && dist(P, R) < r + 1.0E-12) return true;
  if (dist(Q, R) < r + 1.0E-12 && dist(Q, P) < p + 1.0E-12) return true;
  if (dist(R, P) < p + 1.0E-12 && dist(R, Q) < q + 1.0E-12) return true;
  if (tri(dist(P, Q), p, q)) {
    vector<point> vp = cccross(P, p, Q, q);
    if (dist(vp[0], R) < r + 1.0E-12) return true;
    if (dist(vp[1], R) < r + 1.0E-12) return true;
  }
  if (tri(dist(Q, R), q, r)) {
    vector<point> vp = cccross(Q, q, R, r);
    if (dist(vp[0], P) < p + 1.0E-12) return true;
    if (dist(vp[1], P) < p + 1.0E-12) return true;
  }
  if (tri(dist(R, P), r, p)) {
    vector<point> vp = cccross(R, r, P, p);
    if (dist(vp[0], Q) < q + 1.0E-12) return true;
    if (dist(vp[1], Q) < q + 1.0E-12) return true;
  }
  return false;
}
int main() {
  double t1, t2;
  scanf("%lf%lf", &t1, &t2);
  point P = read(), Q = read(), R = read();
  if (dist(P, R) + dist(R, Q) < dist(P, Q) + t2 + 1.0E-12) {
    double ans = min(dist(P, R) + dist(R, Q) + t1, dist(P, Q) + t2);
    printf("%.9f\n", ans);
    return 0;
  }
  double low = 0.0, high = min(dist(P, R) + t1, dist(P, Q) + t2), mid;
  int i;
  for (i = 0; i < 100; i++) {
    mid = (high + low) / 2.0;
    if (possible(P, mid, Q, dist(P, Q) + t2 - mid, R, dist(P, R) + t1 - mid))
      low = mid;
    else
      high = mid;
  }
  printf("%.9f\n", mid);
  return 0;
}