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;
int dcmp(double x) {
  if (fabs(x) < 1e-12) return 0;
  return x > 1e-12 ? 1 : -1;
}
struct point {
  double x, y;
  point(double x = 0, double y = 0) : x(x), y(y) {}
  void init() { scanf("%lf %lf", &x, &y); }
  point operator+(point b) const { return point(x + b.x, y + b.y); }
  point operator-(point b) const { return point(x - b.x, y - b.y); }
  point operator/(double b) const { return point(x / b, y / b); }
  point operator*(double b) const { return point(x * b, y * b); }
} st, hm, sp, p1, p2;
struct cir {
  point o;
  double r;
  cir(point o = 0, double r = 0) : o(o), r(r) {}
} c1, c2, c3;
int N, M;
double t1, t2, ans;
double dt, ds, dp, mx;
double l1, r1, mid;
double dis(point a, point b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int ins(cir x, cir y) {
  double a = dis(x.o, y.o), b = x.r, c = y.r;
  if (dcmp(a - (b + c)) > 0) return 0;
  if (dcmp(a - (b + c)) == 0) {
    p1 = x.o - (y.o - x.o) / a * b * dcmp(c * c - b * b - a * a);
    return 1;
  }
  double p = (a + b + c) / 2;
  double s = sqrt(p * (p - a) * (p - b) * (p - c)), x1 = 2 * s / a;
  point m, t = point(-y.o.y + x.o.y, y.o.x - x.o.x);
  m = x.o -
      (y.o - x.o) / a * sqrt(x.r * x.r - x1 * x1) * dcmp(c * c - b * b - a * a);
  t = t / a, t = t * x1;
  p1 = m + t, p2 = m - t;
  return 2;
}
bool cross(double x, double y, double z) {
  if (dcmp(y - (dis(st, hm) + x)) >= 0) return dcmp(dis(st, sp) - x - z) <= 0;
  if (dcmp(x - (dis(st, hm) + y)) >= 0) return dcmp(dis(hm, sp) - y - z) <= 0;
  if (dcmp(z - (dis(st, sp) + x)) >= 0) return dcmp(dis(st, hm) - x - y) <= 0;
  if (dcmp(x - (dis(st, sp) + z)) >= 0) return dcmp(dis(hm, sp) - y - z) <= 0;
  if (dcmp(y - (dis(sp, hm) + z)) >= 0) return dcmp(dis(st, sp) - x - z) <= 0;
  if (dcmp(z - (dis(sp, hm) + y)) >= 0) return dcmp(dis(hm, st) - x - y) <= 0;
  int tmp;
  c1 = cir(st, x), c2 = cir(hm, y), c3 = cir(sp, z);
  if (tmp = ins(c1, c2))
    if (dcmp(c3.r - dis(p1, c3.o)) >= 0)
      return 1;
    else if (tmp > 1 && dcmp(c3.r - dis(p2, c3.o)) >= 0)
      return 1;
  if (tmp = ins(c1, c3))
    if (dcmp(c2.r - dis(p1, c2.o)) >= 0)
      return 1;
    else if (tmp > 1 && dcmp(c2.r - dis(p2, c2.o)) >= 0)
      return 1;
  if (tmp = ins(c3, c2))
    if (dcmp(c1.r - dis(p1, c1.o)) >= 0)
      return 1;
    else if (tmp > 1 && dcmp(c1.r - dis(p2, c1.o)) >= 0)
      return 1;
  return 0;
}
int main() {
  int i, j, get = 0;
  scanf("%lf %lf", &t1, &t2);
  st.init(), hm.init(), sp.init();
  dt = dis(st, hm), ds = dis(hm, sp), dp = dis(st, sp);
  t1 += dp + ds, t2 += dt, mx = max(t1, t2);
  l1 = 0, r1 = min(t2, t1 - ds);
  while (r1 - l1 > 1e-5) {
    mid = (l1 + r1) / 2;
    if (cross(mid, t2 - mid, t1 - ds - mid))
      l1 = mid + 1e-5;
    else
      r1 = mid - 1e-5;
  }
  ans = l1;
  if (dcmp(t2 - dp - ds) >= 0) ans = max(ans, dp + min(t1 - dp, t2 - dp));
  printf("%.10lf\n", ans);
  return 0;
}