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 ep = 1e-10;
struct pnt {
  double x, y;
  pnt(double x = 0, double y = 0) : x(x), y(y) {}
  pnt operator-(pnt a) { return pnt(x - a.x, y - a.y); }
  pnt operator/(double a) { return pnt(x / a, y / a); }
  pnt operator+(pnt a) { return pnt(x + a.x, y + a.y); }
  pnt operator*(double a) { return pnt(x * a, y * a); }
  pnt rot() { return pnt(-y, x); }
  double dist() { return sqrt(x * x + y * y); }
  void input() { scanf("%lf %lf", &x, &y); }
} C, H, S, O[3];
double th, ts, dh, dhs, ds;
double r[3];
int inter_circle(pnt c1, double r1, pnt c2, double r2, pnt *rlt) {
  double d = (c1 - c2).dist();
  if (r1 + r2 + ep < d || r1 + d + ep < r2 || r2 + d + ep < r1) return 0;
  double x = (r1 * r1 - r2 * r2 + d * d) / (d * 2);
  pnt cp = (c1 * (d - x) + c2 * x) / d;
  if (fabs(r1 + r2 - d) < ep || fabs(r1 + d - r2) < ep ||
      fabs(r2 + d - r1) < ep) {
    rlt[0] = cp;
    return 1;
  }
  double h = sqrt(r1 * r1 - x * x);
  pnt dv = (c2 - c1).rot() * h / d;
  rlt[0] = cp - dv, rlt[1] = cp + dv;
  return 2;
}
bool check(double mid) {
  r[0] = mid, O[0] = C;
  r[1] = ts - dhs - mid, O[1] = S;
  r[2] = th - mid, O[2] = H;
  for (int i = 0; i < 3; i++)
    if (abs(r[i]) < ep) r[i] = 0;
  if (r[0] < 0 || r[1] < 0 || r[2] < 0) return 0;
  pnt rlt[5];
  vector<pnt> vec;
  for (int i = 0; i < 3; i++) {
    vec.push_back(O[i]);
    int j = (i + 1) % 3;
    int k = inter_circle(O[i], r[i], O[j], r[j], rlt);
    for (int jj = 0; jj < k; jj++) vec.push_back(rlt[jj]);
  }
  for (auto x : vec) {
    bool flag = 0;
    for (int i = 0; i < 3; i++) {
      if ((O[i] - x).dist() > r[i] + ep) flag = 1;
    }
    if (!flag) return 1;
  }
  return 0;
}
int main() {
  scanf("%lf %lf", &ts, &th);
  C.input();
  H.input();
  S.input();
  H = H - C, S = S - C, C = pnt(0, 0);
  dh = H.dist(), ds = S.dist(), dhs = (H - S).dist();
  th += dh;
  ts += ds + dhs;
  double ans = 0;
  if (th > ds + dhs - ep)
    ans = max(ans, min(th, ts));
  else {
    double st = 0, en = 400;
    while (en - st > ep) {
      double mid = (en + st) / 2;
      if (check(mid))
        st = mid;
      else
        en = mid;
    }
    ans = st;
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}