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;
long double intersecao[2][2];
long double sqrt1(long double x) {
  long double resposta = sqrt(x);
  long double max_a = x + 1e-12;
  long double min_a = x - 1e-12;
  while ((resposta * resposta) > max_a) resposta -= 1e-12;
  while ((resposta * resposta) < min_a) resposta += 1e-12;
  return resposta;
}
void interseption(long double x1, long double y1, long double r1,
                  long double x2, long double y2, long double r2) {
  long double dx = x1 - x2;
  long double dy = y1 - y2;
  long double a = -dx / dy;
  long double b = (dx * dx + dy * dy - r1 * r1 + r2 * r2) / (2 * dy);
  if (dy == 0) {
    intersecao[0][0] = (dx * dx - r1 * r1 + r2 * r2) / (2 * dx);
    intersecao[1][0] = (dx * dx - r1 * r1 + r2 * r2) / (2 * dx);
    intersecao[0][1] = sqrt1(r2 * r2 - intersecao[0][0] * intersecao[0][0]);
    intersecao[1][1] = -sqrt1(r2 * r2 - intersecao[1][0] * intersecao[1][0]);
    intersecao[0][0] += x2;
    intersecao[1][0] += x2;
    intersecao[0][1] += y2;
    intersecao[1][1] += y2;
  } else {
    long double c, c1;
    c1 = ((a * a * b * b) - (a * a + 1) * (b * b - r2 * r2));
    if (c1 < 0) c1 = 0;
    c = sqrt1(c1);
    intersecao[0][0] = (-a * b + c) / (a * a + 1);
    intersecao[1][0] = (-a * b - c) / (a * a + 1);
    intersecao[0][1] = a * intersecao[0][0] + b;
    intersecao[1][1] = a * intersecao[1][0] + b;
    intersecao[0][0] += x2;
    intersecao[1][0] += x2;
    intersecao[0][1] += y2;
    intersecao[1][1] += y2;
  }
}
long double minimo(long double x, long double y) {
  if (x <= y)
    return x;
  else
    return y;
}
long double maximo(long double x, long double y) {
  if (x > y)
    return x;
  else
    return y;
}
int main() {
  long double t1, t2;
  cin >> t1 >> t2;
  long double x_cinema, y_cinema, x_house, y_house, x_shop, y_shop;
  cin >> x_cinema >> y_cinema >> x_house >> y_house >> x_shop >> y_shop;
  long double a = sqrt1((x_cinema - x_house) * (x_cinema - x_house) +
                        (y_cinema - y_house) * (y_cinema - y_house));
  long double c = sqrt1((x_cinema - x_shop) * (x_cinema - x_shop) +
                        (y_cinema - y_shop) * (y_cinema - y_shop));
  long double b = sqrt1((x_shop - x_house) * (x_shop - x_house) +
                        (y_shop - y_house) * (y_shop - y_house));
  long double T1, T2;
  T1 = t1 + c + b;
  T2 = t2 + a;
  int aux = 0;
  int n_loop = 1;
  long double tmp1 = 0, tmp2 = 0;
  cout << fixed << setprecision(10);
  if (b + c <= T2) {
    cout << minimo(T1, T2);
  } else {
    long double min1 = 0;
    long double max1 = minimo(minimo(T1 - b, T2), T1 / 2 + T2 / 2 - b);
    while (max1 - min1 >= 1e-12) {
      long double med1 = (max1 + min1) / 2;
      long double raio1 = T1 - b - med1;
      long double raio2 = T2 - med1;
      long double raio3 = med1;
      n_loop++;
      if (abs(raio2 - raio3) >= a - 1e-12) {
        if (raio2 - raio3 >= a - 1e-12) {
          if (c <= T1 - b + 1e-12)
            min1 = med1;
          else
            max1 = med1;
        } else {
          if (b <= T1 + T2 - b - 2 * med1 + 1e-12)
            min1 = med1;
          else
            max1 = med1;
        }
        aux = 1;
        continue;
      } else {
        interseption(x_house, y_house, raio2, x_cinema, y_cinema, raio3);
        if ((tmp1 = sqrt1((intersecao[0][0] - x_shop) *
                              (intersecao[0][0] - x_shop) +
                          (intersecao[0][1] - y_shop) *
                              (intersecao[0][1] - y_shop)) <= raio1 + 1e-12) ||
            (tmp2 = sqrt1((intersecao[1][0] - x_shop) *
                              (intersecao[1][0] - x_shop) +
                          (intersecao[1][1] - y_shop) *
                              (intersecao[1][1] - y_shop)) <= raio1 + 1e-12)) {
          min1 = med1;
          aux = 2;
          continue;
        }
      }
      if (abs(raio1 - raio2) >= b - 1e-12) {
        if (raio1 - raio2 >= b - 1e-12) {
          if (a <= T2 + 1e-12)
            min1 = med1;
          else
            max1 = med1;
        } else {
          if (c <= T1 - b + 1e-12)
            min1 = med1;
          else
            max1 = med1;
        }
        aux = 3;
        continue;
      } else {
        interseption(x_house, y_house, raio2, x_shop, y_shop, raio1);
        if ((tmp1 =
                 sqrt1((intersecao[0][0] - x_cinema) *
                           (intersecao[0][0] - x_cinema) +
                       (intersecao[0][1] - y_cinema) *
                           (intersecao[0][1] - y_cinema)) <= raio3 + 1e-12) ||
            (tmp2 =
                 sqrt1((intersecao[1][0] - x_cinema) *
                           (intersecao[1][0] - x_cinema) +
                       (intersecao[1][1] - y_cinema) *
                           (intersecao[1][1] - y_cinema)) <= raio3 + 1e-12)) {
          min1 = med1;
          aux = 4;
          continue;
        }
      }
      if (abs(raio3 - raio1) >= c - 1e-12) {
        if (raio3 - raio1 >= c - 1e-12) {
          if (b <= T1 + T2 - b - 2 * med1 + 1e-12)
            min1 = med1;
          else
            max1 = med1;
        } else {
          if (a <= T2 + 1e-12)
            min1 = med1;
          else
            max1 = med1;
        }
        aux = 5;
        continue;
      } else {
        interseption(x_cinema, y_cinema, raio3, x_shop, y_shop, raio1);
        if ((tmp1 = sqrt1((intersecao[0][0] - x_house) *
                              (intersecao[0][0] - x_house) +
                          (intersecao[0][1] - y_house) *
                              (intersecao[0][1] - y_house)) <= raio2 + 1e-12) ||
            (tmp2 = sqrt1((intersecao[1][0] - x_house) *
                              (intersecao[1][0] - x_house) +
                          (intersecao[1][1] - y_house) *
                              (intersecao[1][1] - y_house)) <= raio2 + 1e-12)) {
          min1 = med1;
          aux = 6;
          continue;
        }
      }
      max1 = med1;
      aux = 10;
    }
    cout << min1;
  }
  return 0;
}