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;
int sgn(double x) {
  if (x > eps) return 1;
  if (x < -eps) return -1;
  return 0;
}
struct Point {
  double x, y;
  Point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
  Point operator+(const Point &t) const { return Point(x + t.x, y + t.y); }
  Point operator-(const Point &t) const { return Point(x - t.x, y - t.y); }
  Point operator*(const double &t) const { return Point(x * t, y * t); }
  Point operator/(const double &t) const { return Point(x / t, y / t); }
  double operator*(const Point &t) const { return x * t.y - y * t.x; }
  double operator^(const Point &t) const { return x * t.x + y * t.y; }
  bool operator==(const Point &t) const {
    return sgn(x - t.x) == 0 && sgn(y - t.y) == 0;
  }
  Point normalize() { return Point(x / len(), y / len()); }
  Point rotLeft90() { return Point(-y, x); }
  double len() { return sqrt(x * x + y * y); }
};
struct Circle {
  Point o;
  double r;
  Circle(Point _o = Point(0, 0), double _r = 1.0) : o(_o), r(_r) {}
  bool contain(Point t) { return sgn((t - o).len() - r) <= 0; }
} c[3];
int CirCirIntersect(Circle c1, Circle c2, Point &p1, Point &p2) {
  double d = (c1.o - c2.o).len();
  if (d > c1.r + c2.r + eps) return 0;
  if (d < fabs(c1.r - c2.r) - eps) return 3;
  double dt = (c1.r * c1.r - c2.r * c2.r) / d;
  double d1 = (d + dt) / 2;
  Point dir = c2.o - c1.o;
  dir = dir.normalize();
  Point pcrs = c1.o + dir * d1;
  dir = dir.rotLeft90();
  dt = sqrt(max(c1.r * c1.r - d1 * d1, 0.0));
  p1 = pcrs + dir * dt;
  p2 = pcrs - dir * dt;
  if (sgn((p1 - c1.o) * (c2.o - c1.o)) < 0) swap(p1, p2);
  if (p1 == p2)
    return 1;
  else
    return 2;
}
int main() {
  double t[2];
  scanf("%lf%lf", &t[0], &t[1]);
  for (int i = 0; i < 3; i++) scanf("%lf%lf", &c[i].o.x, &c[i].o.y);
  t[0] += (c[0].o - c[2].o).len();
  t[1] += (c[0].o - c[1].o).len();
  double l = 0, r = min(t[0], t[1]);
  for (int _ = 0; _ < 100; _++) {
    double m = (l + r) / 2;
    c[0].r = m;
    c[1].r = t[1] - m;
    c[2].r = t[0] - m;
    Point p[6];
    int rem = -1;
    bool epty = 0;
    for (int i = 0; i < 3; i++) {
      int ty = CirCirIntersect(c[i], c[(i + 1) % 3], p[i * 2], p[i * 2 + 1]);
      if (!ty) epty = 1;
      if (ty == 3) rem = (i + 2) % 3;
    }
    if (epty) {
      r = m;
      continue;
    }
    bool isok = 0;
    if (rem == -1) {
      for (int i = 0; i < 6; i++) {
        bool flag = 1;
        for (int j = 0; j < 3; j++)
          if (!c[j].contain(p[i])) flag = 0;
        isok |= flag;
      }
    } else {
      isok = 1;
      for (int i = 0; i < 3; i++)
        if (!CirCirIntersect(c[rem], c[i], p[0], p[1])) isok = 0;
    }
    if (isok)
      l = m;
    else
      r = m;
  }
  double res = (l + r) / 2;
  if (t[1] > (c[0].o - c[2].o).len() + (c[2].o - c[1].o).len() - eps)
    res = max(res, min(t[0] + (c[2].o - c[1].o).len(), t[1]));
  printf("%.10f", res);
  return 0;
}