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 long double Eps = 1e-12;
long double Ta, Tb, X1, X2, X3, Y1, Y2, Y3;
long double calc(long double x, long double y) { return sqrt(x * x + y * y); }
long double rcalc(long double x, long double y) {
  return sqrt(max(x * x - y * y, (long double)0.0000000000));
}
int part(long double X1, long double Y1, long double T1, long double X2,
         long double Y2, long double T2, long double X3, long double Y3,
         long double T3) {
  int cover = 0;
  long double D2 = calc(X1 - X2, Y1 - Y2);
  long double D3 = calc(X1 - X3, Y1 - Y3);
  if (D3 + T3 + Eps < T1) return 0;
  if (D2 + T2 + Eps < T1) return 0;
  long double Ang1, Ang2, Ang3, Ang4;
  long double A, B, C, D, E;
  if (D2 + T1 <= T2 - Eps)
    cover++, Ang1 = Ang2 = -10.0;
  else {
    A = 2 * (X2 - X1);
    B = 2 * (Y2 - Y1);
    C = T2 * T2 - T1 * T1 - (X2 - X1) * (X2 + X1) - (Y2 - Y1) * (Y2 + Y1);
    D = abs(A * X1 + B * Y1 + C) / calc(A, B);
    E = rcalc(T1, D);
    long double ang1 = atan2(Y2 - Y1, X2 - X1);
    long double ang2 = atan2(E, D);
    Ang1 = ang1 + ang2;
    if (Ang1 - Eps > abs(atan2(0, -1))) Ang1 -= 2 * abs(atan2(0, -1));
    Ang2 = ang1 - ang2;
    if (Ang2 + Eps < -abs(atan2(0, -1))) Ang2 += 2 * abs(atan2(0, -1));
  }
  if (D3 + T1 <= T3 - Eps)
    cover++, Ang3 = Ang4 = -10.0;
  else {
    A = 2 * (X3 - X1);
    B = 2 * (Y3 - Y1);
    C = T3 * T3 - T1 * T1 - (X3 - X1) * (X3 + X1) - (Y3 - Y1) * (Y3 + Y1);
    D = abs(A * X1 + B * Y1 + C) / calc(A, B);
    E = rcalc(T1, D);
    long double ang1 = atan2(Y3 - Y1, X3 - X1);
    long double ang2 = atan2(E, D);
    Ang3 = ang1 + ang2;
    if (Ang3 - Eps > abs(atan2(0, -1))) Ang3 -= 2 * abs(atan2(0, -1));
    Ang4 = ang1 - ang2;
    if (Ang4 + Eps < -abs(atan2(0, -1))) Ang4 += 2 * abs(atan2(0, -1));
  }
  if (cover == 2) return 1;
  if (cover == 1 && (Ang1 != -10.0 || Ang3 != -10.0)) return 1;
  if (Ang2 - Eps > Ang1)
    if (Ang4 - Eps > Ang3)
      return 1;
    else if (Ang4 + Eps <= Ang1 || Ang3 - Eps >= Ang2)
      return 1;
    else
      return 0;
  else if (Ang4 - Eps > Ang3)
    if (Ang3 - Eps >= Ang2 || Ang4 + Eps <= Ang1)
      return 1;
    else
      return 0;
  else if (Ang3 + Eps < Ang2 || Ang4 - Eps > Ang1)
    return 0;
  else
    return 1;
}
int check(long double T1) {
  long double T3 = Ta - T1 - calc(X2 - X3, Y2 - Y3);
  long double T2 = Tb - T1;
  if (T3 <= 0 || T2 < 0) return 0;
  if (calc(X1 - X3, Y1 - Y3) - Eps > T1 + T3) return 0;
  if (calc(X2 - X3, Y2 - Y3) - Eps > T3 + T2) return 0;
  if (calc(X1 - X2, Y1 - Y2) - Eps > T1 + T2) return 0;
  if (part(X1, Y1, T1, X2, Y2, T2, X3, Y3, T3)) return 1;
  if (part(X2, Y2, T2, X1, Y1, T1, X3, Y3, T3)) return 1;
  if (part(X3, Y3, T3, X1, Y1, T1, X2, Y2, T2)) return 1;
  return 0;
}
int main() {
  cin >> Ta >> Tb;
  cin >> X1 >> Y1;
  cin >> X2 >> Y2;
  cin >> X3 >> Y3;
  long double TD = calc(X1 - X3, Y1 - Y3) + calc(X2 - X3, Y2 - Y3);
  Ta += TD;
  Tb += calc(X1 - X2, Y1 - Y2);
  if (TD <= Ta && TD <= Tb) {
    printf("%.8lf\n", (double)min(Ta, Tb));
    return 0;
  }
  long double L = Eps;
  long double R = min(Ta, Tb);
  for (; L + Eps < R;) {
    long double mid = (L + R) / 2;
    if (check(mid))
      L = mid;
    else
      R = mid;
  }
  printf("%.8lf\n", (double)L);
}