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 pi = acos(-1);
struct pnt {
  double x, y;
  pnt(double x = 0, double y = 0) : x(x), y(y) {}
  pnt operator-(pnt a) { return pnt(x - a.x, y - a.y); }
  pnt operator+(pnt a) { return pnt(x + a.x, y + a.y); }
  pnt operator*(double a) { return pnt(x * a, y * a); }
  pnt operator/(double a) { return pnt(x / a, y / a); }
  double operator^(pnt a) { return x * a.y - y * a.x; }
  double operator&(pnt a) { return x * a.x + y * a.y; }
  void input() { x = y = 0, scanf("%lf %lf", &x, &y); }
  void print() { printf("%lf %lf\n", x, y); }
} p[12];
double dist(pnt a) { return sqrt(a & a); }
inline pnt rot(pnt p) { return pnt(-p.y, p.x); }
int intersect_circles(pnt c, double r, pnt cc, double rr, pnt p[], int &cnt) {
  double d = dist(c - cc);
  if (r + rr < d - 1e-10 || r + d < rr - 1e-10 || rr + d < r - 1e-10) return 0;
  double x = (r * r - rr * rr + d * d) / (d * 2);
  pnt cp = (c * (d - x) + cc * x) / d;
  if (fabs(r + rr - d) < 1e-10 || fabs(r + d - rr) < 1e-10 ||
      fabs(rr + d - r) < 1e-10) {
    p[cnt++] = cp;
    return 1;
  }
  double h = sqrt(r * r - x * x);
  pnt dv = rot(cc - c) * h / d;
  p[cnt++] = cp - dv;
  p[cnt++] = cp + dv;
  return 2;
}
bool inside_circle(pnt O, double r, pnt a) {
  if (dist(O - a) < r + 1e-10) return 1;
  return 0;
}
int id[12];
double ang[12];
bool cmp(int i, int j) { return ang[i] < ang[j]; }
bool calc(pnt s, double rs, pnt h, double rh, pnt c, double rc) {
  int cnt = 0;
  p[cnt++] = s + pnt(-rs, 0);
  p[cnt++] = s + pnt(rs, 0);
  intersect_circles(s, rs, h, rh, p, cnt);
  intersect_circles(s, rs, c, rc, p, cnt);
  for (int i = cnt; i < 2 * cnt; i++) p[i] = p[i - cnt];
  cnt *= 2;
  for (int i = 0; i < cnt; i++)
    ang[i] = atan2(p[i].y - s.y, p[i].x - s.x), id[i] = i;
  sort(id, id + cnt, cmp);
  for (int i = 0; i < cnt; i++) {
    int j = (i + 1) % cnt;
    int ii = id[i], jj = id[j];
    double Ang = (ang[ii] + ang[jj]) / 2;
    if (fabs(ang[ii] - pi) < 1e-10) Ang -= pi;
    if (fabs(ang[jj] - pi) < 1e-10) Ang += pi;
    pnt mid = pnt(s.x + rs * cos(Ang), s.y + rs * sin(Ang));
    if (inside_circle(s, rs, mid) && inside_circle(h, rh, mid) &&
        inside_circle(c, rc, mid))
      return 1;
  }
  return 0;
}
bool ok(pnt s, double rs, pnt h, double rh, pnt c, double rc) {
  if (rs < -1e-10 || rh < -1e-10) return 0;
  if (calc(s, rs, h, rh, c, rc) || calc(h, rh, s, rs, c, rc) ||
      calc(c, rc, s, rs, h, rh))
    return 1;
  return 0;
}
int main() {
  pnt c, h, s;
  double t1, t2;
  scanf("%lf %lf", &t1, &t2);
  c.input();
  h.input();
  s.input();
  double alan = dist(s - c) + dist(h - s);
  double bob = dist(h - c);
  double ans = 0;
  if (alan < bob + t2 + 1e-10)
    ans = alan + ((bob + t2 - alan) < (t1) ? (bob + t2 - alan) : (t1));
  if (bob + dist(h - s) * 2 < alan + t1 + 1e-10)
    ans = ((ans) > (((bob + t2) < (alan + t1 - 2 * dist(h - s))
                         ? (bob + t2)
                         : (alan + t1 - 2 * dist(h - s))))
               ? (ans)
               : (((bob + t2) < (alan + t1 - 2 * dist(h - s))
                       ? (bob + t2)
                       : (alan + t1 - 2 * dist(h - s)))));
  double st = 0, en = 10000;
  for (int runs = 0; runs < 10000; runs++) {
    double mid = (st + en) / 2;
    if (ok(s, alan + t1 - mid - dist(h - s), h, bob + t2 - mid, c, mid))
      st = mid;
    else
      en = mid;
  }
  ans = ((ans) > (st) ? (ans) : (st));
  printf("%lf\n", ans);
}