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 sqr(double x) { return x * x; }
double eps = 1e-12;
double xcine, ycine, xhome, yhome, xsuper, ysuper, l, r;
double tAlan, tBob;
bool pd(double r1, double r2, double r3, double xcine, double ycine,
        double xhome, double yhome, double xsuper, double ysuper) {
  double b = sqrt(sqr(xhome - xcine) + sqr(yhome - ycine));
  if (b <= r1 + r2 + eps) {
    if (abs(r1 - r2) >= b) {
      b = sqrt(sqr(xsuper - xcine) + sqr(ysuper - ycine));
      if (b <= r1 + r3 + eps) {
        b = sqrt(sqr(xsuper - xhome) + sqr(ysuper - yhome));
        if (b <= r2 + r3 + eps) return true;
      }
    } else {
      double COS = (sqr(r1) + sqr(b) - sqr(r2)) / (2 * r1 * b);
      while (COS > 1) COS = 1;
      while (COS < -1) COS = -1;
      double seita = acos(COS);
      double sei = atan2(yhome - ycine, xhome - xcine);
      double rad1 = sei + seita;
      double rad2 = sei - seita;
      double xx1 = xcine + r1 * cos(rad1);
      double yyy = ycine + r1 * sin(rad1);
      double xx2 = xcine + r1 * cos(rad2);
      double yy2 = ycine + r1 * sin(rad2);
      b = sqrt(sqr(xx1 - xsuper) + sqr(yyy - ysuper));
      if (b - eps <= r3) return true;
      b = sqrt(sqr(xx2 - xsuper) + sqr(yy2 - ysuper));
      if (b - eps <= r3) return true;
    }
  }
  return false;
}
bool ok(double t) {
  bool flag = false;
  double r1 = t;
  double r2 = tBob - t;
  double r3 = tAlan - t;
  flag |= pd(r1, r2, r3, xcine, ycine, xhome, yhome, xsuper, ysuper);
  flag |= pd(r1, r3, r2, xcine, ycine, xsuper, ysuper, xhome, yhome);
  flag |= pd(r2, r3, r1, xhome, yhome, xsuper, ysuper, xcine, ycine);
  return flag;
}
int main() {
  scanf("%lf%lf", &tAlan, &tBob);
  scanf("%lf%lf", &xcine, &ycine);
  scanf("%lf%lf", &xhome, &yhome);
  scanf("%lf%lf", &xsuper, &ysuper);
  if (sqrt(sqr(xcine - xsuper) + sqr(ycine - ysuper)) +
          sqrt(sqr(xsuper - xhome) + sqr(ysuper - yhome)) <=
      tBob + sqrt(sqr(xcine - xhome) + sqr(ycine - yhome))) {
    tAlan = tAlan + sqrt(sqr(xcine - xsuper) + sqr(ycine - ysuper)) +
            sqrt(sqr(xsuper - xhome) + sqr(ysuper - yhome));
    tBob = tBob + sqrt(sqr(xcine - xhome) + sqr(ycine - yhome));
    printf("%0.4lf", min(tAlan, tBob));
    return 0;
  }
  tAlan = tAlan + sqrt(sqr(xcine - xsuper) + sqr(ycine - ysuper));
  tBob = tBob + sqrt(sqr(xcine - xhome) + sqr(ycine - yhome));
  l = 0;
  r = min(tAlan, tBob);
  while (l + eps < r) {
    double mid = (l + r) / 2;
    if (ok(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%0.6lf", l);
}