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 time1, time2, sx, sy, ax, bx, ay, by, t[2], x[3], y[3], fir;
double dist(double x1, double y1, double x2, double y2) {
  return (sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2))));
}
double get_time(double xx, double yy) {
  double td1, td2;
  td1 = time1 - dist(sx, sy, xx, yy) - dist(xx, yy, ax, ay);
  td2 = time2 - dist(sx, sy, xx, yy) - dist(xx, yy, bx, by);
  if (td1 > -0.0000000001) td1 = time1 - dist(xx, yy, ax, ay);
  if (td2 > -0.0000000001) td2 = time2 - dist(xx, yy, bx, by);
  return min(td1, td2);
}
double find_ans() {
  double Tx = -894, Ty = -234, temp, tx, ty;
  int k, j;
  for (double it = 20000; it > 0.00000001;
       tx = 0, ty = 0, temp = get_time(Tx, Ty)) {
    for (int jj = 0; jj <= 250; ++jj) {
      k = rand() % 2000 - 1000, j = rand() % 2000 - 1000;
      if (k != 0 && j != 0 &&
          get_time(Tx + it * k, Ty + it * j) - temp > 0.000001)
        temp = get_time(Tx + it * k, Ty + it * j), tx = it * k, ty = it * j;
    }
    if (tx + ty == 0)
      it *= 0.99;
    else
      while (get_time(Tx + tx, Ty + ty) - get_time(Tx, Ty) > 0.000001)
        Tx += tx, Ty += ty;
  }
  return get_time(Tx, Ty);
}
int main() {
  scanf("%lf %lf %lf %lf %lf %lf %lf %lf", t + 1, t, x, y, x + 1, y + 1, x + 2,
        y + 2);
  time1 = t[0] + dist(x[0], y[0], x[1], y[1]);
  time2 = t[1] + dist(x[0], y[0], x[2], y[2]);
  sx = x[0], sy = y[0];
  ax = x[1], ay = y[1];
  bx = x[2], by = y[2];
  fir = find_ans();
  if (dist(x[0], y[0], x[2], y[2]) + dist(x[2], y[2], x[1], y[1]) <=
      dist(x[0], y[0], x[1], y[1]) + t[0]) {
    time1 = t[0] + dist(x[0], y[0], x[1], y[1]) - dist(x[0], y[0], x[2], y[2]);
    time2 = t[1] + dist(x[2], y[2], x[1], y[1]);
    sx = x[2], sy = y[2];
    ax = x[1], ay = y[1];
    bx = x[1], by = y[1];
    fir = max(fir, find_ans() + dist(x[0], y[0], x[2], y[2]));
  }
  printf("%0.10f", fir);
  return 0;
}