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;
inline int read() {
  int ret = 0, f = 1;
  char c = getchar();
  while (c < 48 || c > 57) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= 48 && c <= 57) ret = ret * 10 + c - 48, c = getchar();
  return ret * f;
}
long long u;
double lx, ly, rx, ry, L_T, o, h, op, T, t1, t2, uu, vv, g, a[5], b[5], n_x,
    n_y, nx, ny;
inline double di(int u, int v) {
  return sqrt((a[u] - a[v]) * (a[u] - a[v]) + (b[u] - b[v]) * (b[u] - b[v]));
}
inline double get_fc(double x, double y) {
  uu = sqrt((a[2] - x) * (a[2] - x) + (b[2] - y) * (b[2] - y));
  vv = sqrt((a[3] - x) * (a[3] - x) + (b[3] - y) * (b[3] - y));
  g = min(t1 - vv - di(3, 2), t2 - uu) -
      sqrt((a[1] - x) * (a[1] - x) + (b[1] - y) * (b[1] - y));
  if (g < -1e-8) return -1;
  g = sqrt((a[1] - x) * (a[1] - x) + (b[1] - y) * (b[1] - y)) + g;
  return g;
}
inline bool solve() {
  u = T * 2e8;
  h = ((long long)rand() * rand() % 2099999999 * rand() % 99999999999999 +
       rand()) %
          u -
      T * 1e8;
  op = (double)h / 1e8;
  o = sqrt(T * T - op * op);
  ny = n_y + op;
  if (rand() & 1)
    nx = n_x - o;
  else
    nx = n_x + o;
  if (get_fc(n_x, n_y) < get_fc(nx, ny)) {
    n_x = nx, n_y = ny;
    return 1;
  }
  return 0;
}
inline bool dk() {
  if (a[1] == a[2] && a[2] == a[3]) return 1;
  if (a[1] == a[2]) return 0;
  if (a[2] == a[3]) return 0;
  if (fabs((double)(b[1] - b[2]) / (a[1] - a[2]) -
           (double)(b[1] - b[3]) / (a[1] - a[3])) < 1e-8)
    return 1;
  return 0;
}
namespace wqy {
inline double ch(double x, double y) {
  double t = di(2, 3) +
             sqrt((a[1] - x) * (a[1] - x) + (b[1] - y) * (b[1] - y)) +
             sqrt((a[3] - x) * (a[3] - x) + (b[3] - y) * (b[3] - y));
  if (t <= t1 + 1e-8) return 1;
  return 0;
}
int main() {
  if (dk()) {
    if (fabs(di(1, 2) + di(1, 3) - di(2, 3)) < 1e-8) {
      printf("%.9lf\n", min(t2, (t1 - di(1, 3) - di(3, 2)) / 2));
      return 0;
    }
    printf("%.9lf\n", t2);
    return 0;
  }
  lx = a[1];
  ly = b[1];
  rx = a[2];
  ry = b[2];
  for (int i = 1; i <= 200; ++i) {
    double mx = (lx + rx) / 2;
    double my = (ly + ry) / 2;
    if (ch(mx, my)) {
      lx = mx;
      ly = my;
    } else {
      rx = mx;
      ry = my;
    }
  }
  uu = sqrt((a[1] - lx) * (a[1] - lx) + (b[1] - ly) * (b[1] - ly));
  printf("%.9lf\n", uu);
  return 0;
}
}  // namespace wqy
namespace cyb {
inline double ch(double x, double y) {
  double t = sqrt((a[1] - x) * (a[1] - x) + (b[1] - y) * (b[1] - y)) +
             sqrt((a[2] - x) * (a[2] - x) + (b[2] - y) * (b[2] - y));
  if (t <= t2 + 1e-8) return 1;
  return 0;
}
int main() {
  lx = a[1];
  ly = b[1];
  rx = a[3];
  ry = b[3];
  for (int i = 1; i <= 200; ++i) {
    double mx = (lx + rx) / 2;
    double my = (ly + ry) / 2;
    if (ch(mx, my))
      lx = mx, ly = my;
    else
      rx = mx, ry = my;
  }
  uu = sqrt((a[1] - lx) * (a[1] - lx) + (b[1] - ly) * (b[1] - ly));
  printf("%.9lf\n", uu);
  return 0;
}
}  // namespace cyb
int main() {
  t1 = read();
  t2 = read();
  a[1] = read();
  b[1] = read();
  a[2] = read();
  b[2] = read();
  a[3] = read();
  b[3] = read();
  t1 += di(1, 3) + di(3, 2);
  t2 += di(1, 2);
  if (di(1, 3) + di(3, 2) - 1e-8 <= t2) {
    printf("%.9lf\n", min(t1, t2));
    exit(0);
  }
  if (t1 - di(1, 3) - di(3, 2) < 1e-8) {
    if (t2 - di(1, 2) < 1e-8) {
      if (!dk()) {
        puts("0");
        return 0;
      }
      if (fabs(di(1, 2) + di(1, 3) - di(2, 3)) < 1e-8) {
        printf("%.9lf\n", 0);
        return 0;
      }
      printf("%.9lf\n", t2);
      return 0;
    }
    return cyb::main();
  }
  if (t2 - di(1, 2) < 1e-8) return wqy::main();
  n_x = a[1];
  n_y = b[1];
  L_T = di(1, 3);
  L_T = max(L_T, di(1, 2));
  L_T = max(L_T, di(2, 3));
  T = L_T;
  while (T > 1e-8) {
    for (int i = 1; i <= 1000; ++i)
      if (solve()) continue;
    T *= 0.9;
  }
  printf("%.9lf\n", get_fc(n_x, n_y));
}