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;
double t1, t2, cimx, cimy, fx, fy, sx, sy;
double limit1, limit2, x1, y11, x2, y22;
int dcmp(double x) {
  if (fabs(x) < 1e-10) return 0;
  if (x > 1e-10)
    return 1;
  else
    return -1;
}
double dis(double xx, double xy, double yx, double yy) {
  return sqrt((xx - yx) * (xx - yx) + (xy - yy) * (xy - yy));
}
bool pan(double xx, double xy, double rx, double yx, double yy, double ry) {
  return dcmp(dis(xx, xy, yx, yy) - rx - ry) <= 0;
}
bool in(double xx, double xy, double yx, double yy, double ry) {
  return dcmp(ry - dis(xx, xy, yx, yy)) >= 0;
}
bool ok(double xx, double xy, double rx, double yx, double yy, double ry) {
  return dcmp(fabs(ry - rx) - dis(xx, xy, yx, yy)) >= 0;
}
double SS(double x, double y, double z) {
  double p = (x + y + z) / 2.0;
  return sqrt(p * (p - x) * (p - y) * (p - z));
}
void getpoint(double xx, double xy, double rx, double yx, double yy,
              double ry) {
  if (dcmp(dis(xx, xy, yx, yy) - rx - ry) == 0) {
    double nowx, nowy;
    nowx = yx - xx;
    nowy = yy - xy;
    nowx /= dis(xx, xy, yx, yy), nowy /= dis(xx, xy, yx, yy);
    nowx *= rx, nowy *= rx;
    x1 = x2 = xx + nowx;
    y11 = y22 = xy + nowy;
    return;
  }
  double dist = dis(xx, xy, yx, yy);
  double area = SS(rx, ry, dist);
  double h = area * 2.0 / dist;
  double kk = sqrt(rx * rx - h * h);
  double nowx, nowy, t = kk / dist;
  nowx = xx + t * (-xx + yx);
  nowy = xy + t * (-xy + yy);
  double now1x, now1y;
  now1x = xx - nowx;
  now1y = xy - nowy;
  swap(now1x, now1y);
  now1y *= -1;
  double distt = dis(xx, xy, nowx, nowy);
  now1x /= distt, now1y /= distt;
  now1x *= h, now1y *= h;
  x1 = now1x + nowx, y11 = now1y + nowy;
  x2 = nowx - now1x, y22 = nowy - now1y;
  return;
}
bool check(double x) {
  double r1 = limit2 - x, r2 = limit1 - dis(fx, fy, sx, sy) - x;
  if (dcmp(r1) <= 0 || dcmp(r2) <= 0) return false;
  bool u1;
  u1 = ok(fx, fy, r1, cimx, cimy, x);
  if (u1 == true && pan(fx, fy, r1, sx, sy, r2) == true) return true;
  u1 = ok(sx, sy, r2, cimx, cimy, x);
  if (u1 == true && pan(sx, sy, r2, fx, fy, r1) == true) return true;
  u1 = ok(fx, fy, r1, sx, sy, r2);
  if (u1 == true && pan(fx, fy, r1, cimx, cimy, x) == true) return true;
  getpoint(fx, fy, r1, cimx, cimy, x);
  if (in(x1, y11, sx, sy, r2) == true || in(x2, y22, sx, sy, r2) == true)
    return true;
  getpoint(sx, sy, r2, cimx, cimy, x);
  if (in(x1, y11, fx, fy, r1) == true || in(x2, y22, fx, fy, r1) == true)
    return true;
  getpoint(fx, fy, r1, sx, sy, r2);
  if (in(x1, y11, cimx, cimy, x) == true || in(x2, y22, cimx, cimy, x) == true)
    return true;
  return false;
}
double find(double x, double y) {
  double l = x, r = y, mid = (x + y) / 2.0;
  while (dcmp(r - l) == 1) {
    mid = (l + r) / 2.0;
    bool u = check(mid);
    if (u == true)
      l = mid;
    else
      r = mid;
  }
  return mid;
}
void work() {
  limit1 = dis(cimx, cimy, sx, sy) + dis(sx, sy, fx, fy) + t1;
  limit2 = dis(cimx, cimy, fx, fy) + t2;
  if (dcmp(dis(cimx, cimy, sx, sy) + dis(sx, sy, fx, fy) - limit2) <= 0) {
    printf("%.10lf\n", min(limit1, limit2));
    return;
  }
  printf("%.10lf\n", find(0, 200));
}
int main() {
  scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &t1, &t2, &cimx, &cimy, &fx, &fy, &sx, &sy);
  work();
  return 0;
}