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 eps = 1e-12;
struct dot {
  double x, y;
  dot() {}
  dot(double x1, double y1) {
    x = x1;
    y = y1;
  }
  dot operator+(const dot &o) { return dot(x + o.x, y + o.y); }
  dot operator-(const dot &o) { return dot(x - o.x, y - o.y); }
  void make(double d) {
    double k = sqrt(x * x + y * y);
    k = d / k;
    x *= k;
    y *= k;
  }
} p[5], a, b;
double r[5], a1, a2;
int t1, t2;
void Init() {
  scanf("%d%d", &t1, &t2);
  scanf("%lf%lf", &p[1].x, &p[1].y);
  scanf("%lf%lf", &p[3].x, &p[3].y);
  scanf("%lf%lf", &p[2].x, &p[2].y);
}
double dis(dot a, dot b) {
  return ((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y));
}
double mysqrt(double x) {
  if (x <= eps) return 0;
  return sqrt(x);
}
void cut(int i, int j) {
  double dd, d, x, y;
  dot f1, f2;
  dd = dis(p[i], p[j]);
  d = sqrt(dd);
  x = ((r[i]) * (r[i])) - ((r[j]) * (r[j])) + dd;
  x /= (2 * d);
  y = mysqrt(((r[i]) * (r[i])) - ((x) * (x)));
  f1 = p[j] - p[i];
  f1.make(x);
  f2 = f1;
  swap(f2.x, f2.y);
  f2.x = -f2.x;
  f2.make(y);
  a = p[i] + f1 + f2;
  b = p[i] + f1 - f2;
}
bool in(dot a, int k) {
  double d = dis(a, p[k]);
  return d <= ((r[k]) * (r[k])) + eps;
}
int get(int i, int j) {
  if (r[i] > r[j]) swap(i, j);
  double d = sqrt(dis(p[i], p[j]));
  if (d > r[i] + r[j] + eps) return 0;
  if (d < r[j] - r[i] - eps) return 1;
  return 2;
}
bool okay(double d) {
  r[1] = d;
  r[2] = a1 + t1 - d;
  r[3] = a2 + t2 - d;
  for (int i = 1; i <= 2; ++i)
    for (int j = i + 1; j <= 3; ++j) {
      int p = get(i, j), k = 6 - i - j;
      if (p == 0) return 0;
      if (p == 1) {
        int t = i, l;
        if (r[t] > r[j]) t = j;
        l = get(t, k);
        if (l == 0) return 0;
        return 1;
      }
      cut(i, j);
      if (in(a, k) || in(b, k)) return 1;
    }
  return 0;
}
void Work() {
  double tmp;
  a1 = sqrt(dis(p[1], p[2]));
  a2 = sqrt(dis(p[1], p[3]));
  tmp = a1 + sqrt(dis(p[2], p[3]));
  if (tmp <= a2 + t2 + eps) {
    tmp += t1;
    tmp = ((tmp) < (a2 + t2) ? (tmp) : (a2 + t2));
    printf("%.6lf\n", tmp);
    return;
  }
  double l = 0, r = a2 + t2, mid;
  for (int i = 1; i <= 200; ++i) {
    mid = (l + r) * 0.5;
    if (okay(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.6lf\n", l);
}
int main() {
  Init();
  Work();
  return 0;
}