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;
double cx, cy, hx, hy, sx, sy;
long double dis(long double x1, long double y1, long double x2,
                long double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
double min(long double A, long double B) {
  if (A < B)
    return A;
  else
    return B;
}
double max(long double A, long double B) {
  if (A > B)
    return A;
  else
    return B;
}
bool Ck1(long double x1, long double y1, long double r1, long double x2,
         long double y2, long double r2, long double x3, long double y3,
         long double r3) {
  long double l = dis(x1, y1, x2, y2);
  long double x = (r1 * r1 - r2 * r2 + l * l) / 2 / l;
  long double dx = x2 - x1, dy = y2 - y1;
  dx /= l, dy /= l;
  long double tx = dx * x + x1, ty = dy * x + y1;
  swap(dx, dy);
  long double t = (r1 * r1 - x * x) + 1E-9;
  long double h = sqrt(t);
  if (dis(tx - dx * h, ty + dy * h, x3, y3) < r3 - 1E-8 ||
      dis(tx + dx * h, ty - dy * h, x3, y3) <= r3 - 1E-8)
    return true;
  return false;
}
bool chk(long double x1, long double y1, long double r1, long double x2,
         long double y2, long double r2, long double x3, long double y3,
         long double r3) {
  long double d12 = dis(x1, y1, x2, y2);
  if (r1 + r2 <= d12 - 1E-7 || r1 + r3 <= dis(x1, y1, x3, y3) - 1E-7 ||
      r2 + r3 <= dis(x2, y2, x3, y3) - 1E-7)
    return false;
  if (dis(x1, y1, x2, y2) + min(r1, r2) <= max(r2, r1)) return true;
  if (dis(x1, y1, x3, y3) + min(r1, r3) <= max(r3, r1)) return true;
  if (dis(x3, y3, x2, y2) + min(r3, r2) <= max(r2, r3)) return true;
  if (Ck1(x1, y1, r1, x2, y2, r2, x3, y3, r3)) return true;
  if (Ck1(x1, y1, r1, x3, y3, r3, x2, y2, r2)) return true;
  if (Ck1(x3, y3, r3, x2, y2, r2, x1, y1, r1)) return true;
  return false;
}
int main() {
  scanf("%lf%lf", &t1, &t2);
  scanf("%lf%lf", &cx, &cy);
  scanf("%lf%lf", &hx, &hy);
  scanf("%lf%lf", &sx, &sy);
  t1 += dis(cx, cy, sx, sy);
  t2 += dis(cx, cy, hx, hy);
  if (dis(cx, cy, sx, sy) + dis(sx, sy, hx, hy) <= t2) {
    printf("%.8lf\n", min(t2, t1 + dis(sx, sy, hx, hy)));
    return 0;
  }
  long double l = 0, r = min(t1, t2);
  if (t1 > t2) {
    swap(hx, sx);
    swap(hy, sy);
    swap(t1, t2);
  }
  while (l + 1E-7 < r) {
    long double mid = (l + r) / 2;
    if (chk(sx, sy, t1 - mid, hx, hy, t2 - mid, cx, cy, mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.8lf\n", double(r));
  return 0;
}