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 double eps = 1e-10;
int t1, t2;
int xa, ya, xb, yb, xc, yc;
double T1, T2, tbc;
bool in(double x, double y, double x0, double y0, double r) {
  double d = hypot(x - x0, y - y0);
  return d <= r + eps;
}
bool common(double x0, double y0, double r0, double x1, double y1, double r1) {
  double d = hypot(x0 - x1, y0 - y1);
  return d <= r0 + r1 + eps;
}
bool test(double x0, double y0, double r0, double x1, double y1, double r1,
          double x2, double y2, double r2) {
  double d = hypot(x0 - x1, y0 - y1);
  if (d > r0 + r1 + eps) return 0;
  if (fabs(r0 - r1) + eps >= d)
    return r0 < r1 ? common(x0, y0, r0, x2, y2, r2)
                   : common(x1, y1, r1, x2, y2, r2);
  double t = acos((d * d + r0 * r0 - r1 * r1) / 2 / r0 / d),
         t0 = atan2(y1 - y0, x1 - x0);
  if (d + eps > r0 + r1) t = 0;
  double xa = x0 + r0 * cos(t + t0), ya = y0 + r0 * sin(t + t0),
         xb = x0 + r0 * cos(t0 - t), yb = y0 + r0 * sin(t0 - t);
  return in(xa, ya, x2, y2, r2) || in(xb, yb, x2, y2, r2);
}
bool check(double x) {
  if (x + tbc > T1 + eps) return 0;
  double ra = x, rb = T1 - tbc - x, rc = T2 - x;
  if (rb < eps) return in(xb, yb, xa, ya, ra) && in(xb, yb, xc, yc, rc);
  return test(xa, ya, ra, xb, yb, rb, xc, yc, rc) ||
         test(xa, ya, ra, xc, yc, rc, xb, yb, rb) ||
         test(xb, yb, rb, xc, yc, rc, xa, ya, ra);
}
int main() {
  scanf("%d%d%d%d%d%d%d%d", &t1, &t2, &xa, &ya, &xc, &yc, &xb, &yb);
  tbc = hypot(xc - xb, yc - yb);
  T1 = hypot(xb - xa, yb - ya) + tbc + t1;
  T2 = hypot(xc - xa, yc - ya) + t2;
  if (T1 - t1 <= T2 + eps) return printf("%.10lf\n", min(T1, T2)), 0;
  double l = 0, r = min(T1, T2);
  while (r - l > eps) {
    double mid = l * 0.5 + r * 0.5;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.10lf\n", l);
  return 0;
}