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>
const double Exp = 1e-12;
using namespace std;
struct point {
  double x, y;
};
point A, B, C;
double L1, L2;
double a, b, c;
double sim_ans;
double dis(point &A, point &B) {
  return sqrt(((A.x - B.x) * (A.x - B.x)) + ((A.y - B.y) * (A.y - B.y)));
}
double muilt(point &P, point &A, point &B) {
  return (A.x - P.x) * (B.y - P.y) - (A.y - P.y) * (B.x - P.x);
}
double dot(point &P, point &A, point &B) {
  return (A.x - P.x) * (B.x - P.x) + (A.y - P.y) * (B.y - P.y);
}
bool cross(point &A, point &B, point &C, point &D, point &F) {
  if (muilt(A, B, C) * muilt(A, B, D) > 0 ||
      muilt(C, D, A) * muilt(C, D, B) > 0)
    return false;
  double kA = fabs(muilt(A, C, D)), kB = fabs(muilt(B, C, D)),
         k = kA / (kA + kB);
  F.x = A.x + (B.x - A.x) * k;
  F.y = A.y + (B.y - A.y) * k;
  return true;
}
void special_doit() {
  if (dot(C, A, B) <= 0)
    cout << sim_ans << endl;
  else {
    if (dot(A, B, C) <= 0) {
      if (L2 >= 2 * dis(A, C))
        cout << sim_ans << endl;
      else {
        if (L1 >= 2 * dis(A, B))
          cout << dis(A, B) + L2 << endl;
        else
          cout << L2 / 2 << endl;
      }
    } else {
      if (L2 >= 2 * dis(B, C))
        cout << sim_ans << endl;
      else
        cout << dis(A, B) + L2 / 2 << endl;
    }
  }
}
point update(point P, double r) {
  if (dis(P, A) < Exp) return P;
  double k = r / dis(P, A);
  P.x = A.x + (P.x - A.x) * k;
  P.y = A.y + (P.y - A.y) * k;
  return P;
}
bool solve(double r) {
  double max1 = b + L1 - r;
  double max2 = c + L2 - r;
  point s = update(B, r), t = update(C, r);
  while (dis(s, t) > Exp) {
    point mid;
    mid.x = (s.x + t.x) / 2;
    mid.y = (s.y + t.y) / 2;
    mid = update(mid, r);
    double LB, LC;
    point foc;
    if (cross(A, mid, B, C, foc))
      LB = dis(foc, B), LC = dis(foc, C);
    else
      LB = dis(mid, B), LC = dis(mid, C);
    if (LC < max1 + Exp) {
      if (LB < max2 + Exp)
        return true;
      else
        t = mid;
    } else {
      if (LB < max2 + Exp)
        s = mid;
      else
        return false;
    }
  }
  return true;
}
void doit() {
  cout.precision(10);
  cin >> L1 >> L2 >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
  a = dis(B, C);
  b = dis(A, C);
  c = dis(A, B);
  sim_ans = min(L1 + dis(A, C) + dis(B, C), L2 + dis(A, B));
  if (muilt(A, B, C) == 0) {
    special_doit();
    return;
  }
  if (L2 > dis(A, C) + dis(C, B) - dis(A, B) - Exp ||
      L1 > dis(B, C) * 2 - Exp) {
    cout << sim_ans << endl;
    return;
  }
  double s = 0, t = min(b + L1, c + L2);
  while (t - s > Exp) {
    double mid = (s + t) / 2;
    if (solve(mid))
      s = mid;
    else
      t = mid;
  }
  cout << s << endl;
}
int main() {
  doit();
  return 0;
}